summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Rapoport (Microsoft) <rppt@kernel.org>2026-09-03 18:50:01 +0300
committerAndrew Morton <akpm@linux-foundation.org>2026-10-08 22:54:44 -0700
commit254e7a129e47084ba5710d85d605dc5bc56a06bf (patch)
tree823fc13968f0335644a2e724d4c0be82266419d7
parent569db54d8b7a4ec463a62c444de0d6f5f10e9dc1 (diff)
downloadlinux-next-254e7a129e47084ba5710d85d605dc5bc56a06bf.tar.gz
linux-next-254e7a129e47084ba5710d85d605dc5bc56a06bf.zip
mm/vmalloc: add DEFINE_FREE() for vfree()
... and use it in hid-core, the only place with a cleanup for a vmalloc() allocation. Link: https://lore.kernel.org/20260903-execmem-rox-cache-pmd-v1-v1-4-11beb2a3d249@kernel.org Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Cc: Benjamin Tissoires <bentiss@kernel.org> Cc: Jiri Kosina <jikos@kernel.org> Cc: Luis Chamberalin <mcgrof@kernel.org> Cc: "Uladzislau Rezki (Sony)" <urezki@gmail.com>
-rw-r--r--drivers/hid/hid-core.c4
-rw-r--r--include/linux/vmalloc.h3
2 files changed, 5 insertions, 2 deletions
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index a3ff0514f9cd..ec7c2860c93e 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -944,7 +944,7 @@ static int hid_scan_report(struct hid_device *hid)
hid_parser_reserved
};
- struct hid_parser *parser __free(kvfree) = vzalloc(sizeof(*parser));
+ struct hid_parser *parser __free(vfree) = vzalloc(sizeof(*parser));
if (!parser)
return -ENOMEM;
@@ -1265,7 +1265,7 @@ static int hid_parse_collections(struct hid_device *device)
hid_parser_reserved
};
- struct hid_parser *parser __free(kvfree) = vzalloc(sizeof(*parser));
+ struct hid_parser *parser __free(vfree) = vzalloc(sizeof(*parser));
if (!parser)
return -ENOMEM;
diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
index 6e555e31e622..034a693777ca 100644
--- a/include/linux/vmalloc.h
+++ b/include/linux/vmalloc.h
@@ -3,6 +3,7 @@
#define _LINUX_VMALLOC_H
#include <linux/alloc_tag.h>
+#include <linux/cleanup.h>
#include <linux/sched.h>
#include <linux/spinlock.h>
#include <linux/init.h>
@@ -215,6 +216,8 @@ void *__must_check vrealloc_node_align_noprof(const void *p, size_t size,
extern void vfree(const void *addr);
extern void vfree_atomic(const void *addr);
+DEFINE_FREE(vfree, void *, if (!IS_ERR_OR_NULL(_T)) vfree(_T))
+
extern void *vmap(struct page **pages, unsigned int count,
unsigned long flags, pgprot_t prot);
void *vmap_pfn(unsigned long *pfns, unsigned int count, pgprot_t prot);