diff options
| author | Kees Cook | 2026-02-20 23:49:23 -0800 |
|---|---|---|
| committer | Kees Cook | 2026-02-21 01:02:28 -0800 |
| commit | 69050f8d6d075dc01af7a5f2f550a8067510366f (patch) | |
| tree | bb265f94d9dfa7876c06a5d9f88673d496a15341 /sound/isa | |
| parent | d39a1d7486d98668dd34aaa6732aad7977c45f5a (diff) | |
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/isa')
| -rw-r--r-- | sound/isa/gus/gus_main.c | 2 | ||||
| -rw-r--r-- | sound/isa/gus/gus_mem.c | 2 | ||||
| -rw-r--r-- | sound/isa/gus/gus_mem_proc.c | 4 | ||||
| -rw-r--r-- | sound/isa/gus/gus_pcm.c | 2 | ||||
| -rw-r--r-- | sound/isa/sb/emu8000_pcm.c | 2 | ||||
| -rw-r--r-- | sound/isa/sb/sb16_csp.c | 2 | ||||
| -rw-r--r-- | sound/isa/wavefront/wavefront_synth.c | 2 |
7 files changed, 8 insertions, 8 deletions
diff --git a/sound/isa/gus/gus_main.c b/sound/isa/gus/gus_main.c index 5f50a39c6f16..0b6e56c16e38 100644 --- a/sound/isa/gus/gus_main.c +++ b/sound/isa/gus/gus_main.c @@ -116,7 +116,7 @@ int snd_gus_create(struct snd_card *card, }; *rgus = NULL; - gus = kzalloc(sizeof(*gus), GFP_KERNEL); + gus = kzalloc_obj(*gus, GFP_KERNEL); if (gus == NULL) return -ENOMEM; spin_lock_init(&gus->reg_lock); diff --git a/sound/isa/gus/gus_mem.c b/sound/isa/gus/gus_mem.c index 8d95d8d5abdf..65e5426a43fd 100644 --- a/sound/isa/gus/gus_mem.c +++ b/sound/isa/gus/gus_mem.c @@ -21,7 +21,7 @@ snd_gf1_mem_xalloc(struct snd_gf1_mem *alloc, struct snd_gf1_mem_block *block, { struct snd_gf1_mem_block *pblock, *nblock; - nblock = kmalloc(sizeof(struct snd_gf1_mem_block), GFP_KERNEL); + nblock = kmalloc_obj(struct snd_gf1_mem_block, GFP_KERNEL); if (nblock == NULL) return NULL; *nblock = *block; diff --git a/sound/isa/gus/gus_mem_proc.c b/sound/isa/gus/gus_mem_proc.c index b5e1d1649500..fdb14acaddcf 100644 --- a/sound/isa/gus/gus_mem_proc.c +++ b/sound/isa/gus/gus_mem_proc.c @@ -50,7 +50,7 @@ int snd_gf1_mem_proc_init(struct snd_gus_card * gus) for (idx = 0; idx < 4; idx++) { if (gus->gf1.mem_alloc.banks_8[idx].size > 0) { - priv = kzalloc(sizeof(*priv), GFP_KERNEL); + priv = kzalloc_obj(*priv, GFP_KERNEL); if (priv == NULL) return -ENOMEM; priv->gus = gus; @@ -67,7 +67,7 @@ int snd_gf1_mem_proc_init(struct snd_gus_card * gus) } for (idx = 0; idx < 4; idx++) { if (gus->gf1.rom_present & (1 << idx)) { - priv = kzalloc(sizeof(*priv), GFP_KERNEL); + priv = kzalloc_obj(*priv, GFP_KERNEL); if (priv == NULL) return -ENOMEM; priv->rom = 1; diff --git a/sound/isa/gus/gus_pcm.c b/sound/isa/gus/gus_pcm.c index 9249cbff30f3..b5da8d970b3f 100644 --- a/sound/isa/gus/gus_pcm.c +++ b/sound/isa/gus/gus_pcm.c @@ -638,7 +638,7 @@ static int snd_gf1_pcm_playback_open(struct snd_pcm_substream *substream) struct snd_pcm_runtime *runtime = substream->runtime; int err; - pcmp = kzalloc(sizeof(*pcmp), GFP_KERNEL); + pcmp = kzalloc_obj(*pcmp, GFP_KERNEL); if (pcmp == NULL) return -ENOMEM; pcmp->gus = gus; diff --git a/sound/isa/sb/emu8000_pcm.c b/sound/isa/sb/emu8000_pcm.c index 656a655d618d..a3071cd2e9a8 100644 --- a/sound/isa/sb/emu8000_pcm.c +++ b/sound/isa/sb/emu8000_pcm.c @@ -221,7 +221,7 @@ static int emu8k_pcm_open(struct snd_pcm_substream *subs) struct snd_emu8k_pcm *rec; struct snd_pcm_runtime *runtime = subs->runtime; - rec = kzalloc(sizeof(*rec), GFP_KERNEL); + rec = kzalloc_obj(*rec, GFP_KERNEL); if (! rec) return -ENOMEM; diff --git a/sound/isa/sb/sb16_csp.c b/sound/isa/sb/sb16_csp.c index 9ad71a9fc18d..834b38de9afd 100644 --- a/sound/isa/sb/sb16_csp.c +++ b/sound/isa/sb/sb16_csp.c @@ -117,7 +117,7 @@ int snd_sb_csp_new(struct snd_sb *chip, int device, struct snd_hwdep ** rhwdep) if (err < 0) return err; - p = kzalloc(sizeof(*p), GFP_KERNEL); + p = kzalloc_obj(*p, GFP_KERNEL); if (!p) { snd_device_free(chip->card, hw); return -ENOMEM; diff --git a/sound/isa/wavefront/wavefront_synth.c b/sound/isa/wavefront/wavefront_synth.c index 0d78533e1cfd..0b91b3b28f7f 100644 --- a/sound/isa/wavefront/wavefront_synth.c +++ b/sound/isa/wavefront/wavefront_synth.c @@ -1381,7 +1381,7 @@ wavefront_load_patch (snd_wavefront_t *dev, const char __user *addr) wavefront_patch_info *header; int err; - header = kmalloc(sizeof(*header), GFP_KERNEL); + header = kmalloc_obj(*header, GFP_KERNEL); if (! header) return -ENOMEM; |
