summaryrefslogtreecommitdiff
path: root/sound/synth
diff options
context:
space:
mode:
authorKees Cook <kees@kernel.org>2026-02-20 23:49:23 -0800
committerKees Cook <kees@kernel.org>2026-02-21 01:02:28 -0800
commit69050f8d6d075dc01af7a5f2f550a8067510366f (patch)
treebb265f94d9dfa7876c06a5d9f88673d496a15341 /sound/synth
parentd39a1d7486d98668dd34aaa6732aad7977c45f5a (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/synth')
-rw-r--r--sound/synth/emux/emux.c6
-rw-r--r--sound/synth/emux/emux_effect.c4
-rw-r--r--sound/synth/emux/emux_seq.c8
-rw-r--r--sound/synth/emux/soundfont.c8
-rw-r--r--sound/synth/util_mem.c2
5 files changed, 14 insertions, 14 deletions
diff --git a/sound/synth/emux/emux.c b/sound/synth/emux/emux.c
index 01444fc960d0..f690e8f812d9 100644
--- a/sound/synth/emux/emux.c
+++ b/sound/synth/emux/emux.c
@@ -26,7 +26,7 @@ int snd_emux_new(struct snd_emux **remu)
struct snd_emux *emu;
*remu = NULL;
- emu = kzalloc(sizeof(*emu), GFP_KERNEL);
+ emu = kzalloc_obj(*emu, GFP_KERNEL);
if (emu == NULL)
return -ENOMEM;
@@ -86,8 +86,8 @@ int snd_emux_register(struct snd_emux *emu, struct snd_card *card, int index, ch
emu->card = card;
emu->name = kstrdup_const(name, GFP_KERNEL);
- emu->voices = kcalloc(emu->max_voices, sizeof(struct snd_emux_voice),
- GFP_KERNEL);
+ emu->voices = kzalloc_objs(struct snd_emux_voice, emu->max_voices,
+ GFP_KERNEL);
if (emu->name == NULL || emu->voices == NULL)
return -ENOMEM;
diff --git a/sound/synth/emux/emux_effect.c b/sound/synth/emux/emux_effect.c
index bfe383fa90ba..dacbdf8cd39a 100644
--- a/sound/synth/emux/emux_effect.c
+++ b/sound/synth/emux/emux_effect.c
@@ -272,8 +272,8 @@ void
snd_emux_create_effect(struct snd_emux_port *p)
{
int i;
- p->effect = kcalloc(p->chset.max_channels,
- sizeof(struct snd_emux_effect_table), GFP_KERNEL);
+ p->effect = kzalloc_objs(struct snd_emux_effect_table,
+ p->chset.max_channels, GFP_KERNEL);
if (p->effect) {
for (i = 0; i < p->chset.max_channels; i++)
p->chset.channels[i].private = p->effect + i;
diff --git a/sound/synth/emux/emux_seq.c b/sound/synth/emux/emux_seq.c
index 9d63ac006aa5..9a279d07364d 100644
--- a/sound/synth/emux/emux_seq.c
+++ b/sound/synth/emux/emux_seq.c
@@ -132,12 +132,12 @@ snd_emux_create_port(struct snd_emux *emu, char *name,
int i, type, cap;
/* Allocate structures for this channel */
- p = kzalloc(sizeof(*p), GFP_KERNEL);
+ p = kzalloc_obj(*p, GFP_KERNEL);
if (!p)
return NULL;
- p->chset.channels = kcalloc(max_channels, sizeof(*p->chset.channels),
- GFP_KERNEL);
+ p->chset.channels = kzalloc_objs(*p->chset.channels, max_channels,
+ GFP_KERNEL);
if (!p->chset.channels) {
kfree(p);
return NULL;
@@ -351,7 +351,7 @@ int snd_emux_init_virmidi(struct snd_emux *emu, struct snd_card *card)
if (emu->midi_ports <= 0)
return 0;
- emu->vmidi = kcalloc(emu->midi_ports, sizeof(*emu->vmidi), GFP_KERNEL);
+ emu->vmidi = kzalloc_objs(*emu->vmidi, emu->midi_ports, GFP_KERNEL);
if (!emu->vmidi)
return -ENOMEM;
diff --git a/sound/synth/emux/soundfont.c b/sound/synth/emux/soundfont.c
index 59f3b1b6df4a..01996637d257 100644
--- a/sound/synth/emux/soundfont.c
+++ b/sound/synth/emux/soundfont.c
@@ -230,7 +230,7 @@ newsf(struct snd_sf_list *sflist, int type, char *name)
}
/* not found -- create a new one */
- sf = kzalloc(sizeof(*sf), GFP_KERNEL);
+ sf = kzalloc_obj(*sf, GFP_KERNEL);
if (sf == NULL)
return NULL;
sf->id = sflist->fonts_size;
@@ -309,7 +309,7 @@ sf_zone_new(struct snd_sf_list *sflist, struct snd_soundfont *sf)
{
struct snd_sf_zone *zp;
- zp = kzalloc(sizeof(*zp), GFP_KERNEL);
+ zp = kzalloc_obj(*zp, GFP_KERNEL);
if (!zp)
return NULL;
zp->next = sf->zones;
@@ -342,7 +342,7 @@ sf_sample_new(struct snd_sf_list *sflist, struct snd_soundfont *sf)
{
struct snd_sf_sample *sp;
- sp = kzalloc(sizeof(*sp), GFP_KERNEL);
+ sp = kzalloc_obj(*sp, GFP_KERNEL);
if (!sp)
return NULL;
@@ -1391,7 +1391,7 @@ snd_sf_new(struct snd_sf_callback *callback, struct snd_util_memhdr *hdr)
{
struct snd_sf_list *sflist;
- sflist = kzalloc(sizeof(*sflist), GFP_KERNEL);
+ sflist = kzalloc_obj(*sflist, GFP_KERNEL);
if (!sflist)
return NULL;
diff --git a/sound/synth/util_mem.c b/sound/synth/util_mem.c
index 2fd577c2a8eb..36fa4fc9632c 100644
--- a/sound/synth/util_mem.c
+++ b/sound/synth/util_mem.c
@@ -26,7 +26,7 @@ snd_util_memhdr_new(int memsize)
{
struct snd_util_memhdr *hdr;
- hdr = kzalloc(sizeof(*hdr), GFP_KERNEL);
+ hdr = kzalloc_obj(*hdr, GFP_KERNEL);
if (hdr == NULL)
return NULL;
hdr->size = memsize;