mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
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>
This commit is contained in:
parent
569db54d8b
commit
254e7a129e
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user