diff options
| author | Kees Cook <kees@kernel.org> | 2026-02-20 23:49:23 -0800 |
|---|---|---|
| committer | Kees Cook <kees@kernel.org> | 2026-02-21 01:02:28 -0800 |
| commit | 69050f8d6d075dc01af7a5f2f550a8067510366f (patch) | |
| tree | bb265f94d9dfa7876c06a5d9f88673d496a15341 /fs/notify | |
| parent | d39a1d7486d98668dd34aaa6732aad7977c45f5a (diff) | |
| download | linux-next-69050f8d6d075dc01af7a5f2f550a8067510366f.tar.gz linux-next-69050f8d6d075dc01af7a5f2f550a8067510366f.zip | |
treewide: Replace kmalloc with kmalloc_obj for non-scalar types
This is the result of running the Coccinelle script from
scripts/coccinelle/api/kmalloc_objs.cocci. The script is designed to
avoid scalar types (which need careful case-by-case checking), and
instead replace kmalloc-family calls that allocate struct or union
object instances:
Single allocations: kmalloc(sizeof(TYPE), ...)
are replaced with: kmalloc_obj(TYPE, ...)
Array allocations: kmalloc_array(COUNT, sizeof(TYPE), ...)
are replaced with: kmalloc_objs(TYPE, COUNT, ...)
Flex array allocations: kmalloc(struct_size(PTR, FAM, COUNT), ...)
are replaced with: kmalloc_flex(*PTR, FAM, COUNT, ...)
(where TYPE may also be *VAR)
The resulting allocations no longer return "void *", instead returning
"TYPE *".
Signed-off-by: Kees Cook <kees@kernel.org>
Diffstat (limited to 'fs/notify')
| -rw-r--r-- | fs/notify/fanotify/fanotify_user.c | 2 | ||||
| -rw-r--r-- | fs/notify/group.c | 2 | ||||
| -rw-r--r-- | fs/notify/inotify/inotify_user.c | 2 | ||||
| -rw-r--r-- | fs/notify/mark.c | 2 |
4 files changed, 4 insertions, 4 deletions
diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c index d0b9b984002f..c2dcb25151de 100644 --- a/fs/notify/fanotify/fanotify_user.c +++ b/fs/notify/fanotify/fanotify_user.c @@ -1573,7 +1573,7 @@ static struct fsnotify_event *fanotify_alloc_overflow_event(void) { struct fanotify_event *oevent; - oevent = kmalloc(sizeof(*oevent), GFP_KERNEL_ACCOUNT); + oevent = kmalloc_obj(*oevent, GFP_KERNEL_ACCOUNT); if (!oevent) return NULL; diff --git a/fs/notify/group.c b/fs/notify/group.c index 18446b7b0d49..b56d1c1d9644 100644 --- a/fs/notify/group.c +++ b/fs/notify/group.c @@ -117,7 +117,7 @@ static struct fsnotify_group *__fsnotify_alloc_group( { struct fsnotify_group *group; - group = kzalloc(sizeof(struct fsnotify_group), gfp); + group = kzalloc_obj(struct fsnotify_group, gfp); if (!group) return ERR_PTR(-ENOMEM); diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c index b372fb2c56bd..5e1845f2c25d 100644 --- a/fs/notify/inotify/inotify_user.c +++ b/fs/notify/inotify/inotify_user.c @@ -660,7 +660,7 @@ static struct fsnotify_group *inotify_new_group(unsigned int max_events) if (IS_ERR(group)) return group; - oevent = kmalloc(sizeof(struct inotify_event_info), GFP_KERNEL_ACCOUNT); + oevent = kmalloc_obj(struct inotify_event_info, GFP_KERNEL_ACCOUNT); if (unlikely(!oevent)) { fsnotify_destroy_group(group); return ERR_PTR(-ENOMEM); diff --git a/fs/notify/mark.c b/fs/notify/mark.c index 8e6997e9aebb..691d36104ae2 100644 --- a/fs/notify/mark.c +++ b/fs/notify/mark.c @@ -644,7 +644,7 @@ static int fsnotify_attach_info_to_sb(struct super_block *sb) struct fsnotify_sb_info *sbinfo; /* sb info is freed on fsnotify_sb_delete() */ - sbinfo = kzalloc(sizeof(*sbinfo), GFP_KERNEL); + sbinfo = kzalloc_obj(*sbinfo, GFP_KERNEL); if (!sbinfo) return -ENOMEM; |
