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 /sound/core/timer.c | |
| 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 'sound/core/timer.c')
| -rw-r--r-- | sound/core/timer.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/sound/core/timer.c b/sound/core/timer.c index 9a4a1748ff80..7d10f079b5b3 100644 --- a/sound/core/timer.c +++ b/sound/core/timer.c @@ -151,7 +151,7 @@ struct snd_timer_instance *snd_timer_instance_new(const char *owner) { struct snd_timer_instance *timeri; - timeri = kzalloc(sizeof(*timeri), GFP_KERNEL); + timeri = kzalloc_obj(*timeri, GFP_KERNEL); if (timeri == NULL) return NULL; timeri->owner = kstrdup(owner, GFP_KERNEL); @@ -930,7 +930,7 @@ int snd_timer_new(struct snd_card *card, char *id, struct snd_timer_id *tid, } if (rtimer) *rtimer = NULL; - timer = kzalloc(sizeof(*timer), GFP_KERNEL); + timer = kzalloc_obj(*timer, GFP_KERNEL); if (!timer) return -ENOMEM; timer->tmr_class = tid->dev_class; @@ -1197,7 +1197,7 @@ static int snd_timer_register_system(void) return err; strscpy(timer->name, "system timer"); timer->hw = snd_timer_system; - priv = kzalloc(sizeof(*priv), GFP_KERNEL); + priv = kzalloc_obj(*priv, GFP_KERNEL); if (priv == NULL) { snd_timer_free(timer); return -ENOMEM; @@ -1432,11 +1432,11 @@ static int realloc_user_queue(struct snd_timer_user *tu, int size) struct snd_timer_tread64 *tqueue = NULL; if (tu->tread) { - tqueue = kcalloc(size, sizeof(*tqueue), GFP_KERNEL); + tqueue = kzalloc_objs(*tqueue, size, GFP_KERNEL); if (!tqueue) return -ENOMEM; } else { - queue = kcalloc(size, sizeof(*queue), GFP_KERNEL); + queue = kzalloc_objs(*queue, size, GFP_KERNEL); if (!queue) return -ENOMEM; } @@ -1461,7 +1461,7 @@ static int snd_timer_user_open(struct inode *inode, struct file *file) if (err < 0) return err; - tu = kzalloc(sizeof(*tu), GFP_KERNEL); + tu = kzalloc_obj(*tu, GFP_KERNEL); if (tu == NULL) return -ENOMEM; spin_lock_init(&tu->qlock); @@ -2128,7 +2128,7 @@ static int snd_utimer_create(struct snd_timer_uinfo *utimer_info, if (!utimer_info || utimer_info->resolution == 0) return -EINVAL; - utimer = kzalloc(sizeof(*utimer), GFP_KERNEL); + utimer = kzalloc_obj(*utimer, GFP_KERNEL); if (!utimer) return -ENOMEM; |
