summaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorKees Cook <kees+treewide@kernel.org>2026-09-02 15:31:14 -0700
committerKees Cook <kees@kernel.org>2026-09-04 21:37:00 -0700
commit3a2c4d55e32ad65efebdb6de44eef3bfa08bb49d (patch)
treec65086f9bdcd48c6360fb7cb4598bca084da1f32 /sound
parent90feea391c64fc43bf44184fcf2b243ab991ce47 (diff)
treewide: refresh kmalloc_obj() conversions
This is another run of the Coccinelle script for converting kmalloc() family of allocations to kmalloc_obj() via the existing rules in scripts/coccinelle/api/kmalloc_objs.cocci This catches both the set of kmalloc() uses added since the first kmalloc_obj() conversions in v7.0 and adds a large group missed in the first pass due to Coccinelle not interacting well with the cleanup.h scoped_...() family of macros[1]. I worked around this with spatch's "--macro-file" argument to a file with all the scoped_...() macros mapped to Coccinelle's YACFE_ITERATOR[2] as that was the closest viable control flow indicator I could find. Build tested allmodconfig on x86, arm64, arm, loongarch, mips, powerpc, riscv, and s390 with no new warnings. Link: https://lore.kernel.org/lkml/202609021314.8A9C0B8@keescook/ [1] Link: https://github.com/coccinelle/coccinelle/blob/master/standard.h [2] Signed-off-by: Kees Cook <kees+treewide@kernel.org>
Diffstat (limited to 'sound')
-rw-r--r--sound/core/compress_offload.c4
-rw-r--r--sound/core/control.c6
-rw-r--r--sound/core/control_led.c2
-rw-r--r--sound/core/init.c2
-rw-r--r--sound/core/misc.c2
-rw-r--r--sound/core/oss/mixer_oss.c2
-rw-r--r--sound/core/pcm_native.c2
-rw-r--r--sound/core/seq/oss/seq_oss_synth.c2
-rw-r--r--sound/core/seq/seq_clientmgr.c2
-rw-r--r--sound/core/seq/seq_virmidi.c2
-rw-r--r--sound/core/timer.c2
-rw-r--r--sound/drivers/aloop.c4
-rw-r--r--sound/isa/gus/gus_dma.c2
-rw-r--r--sound/pci/cs46xx/cs46xx_lib.c2
-rw-r--r--sound/pci/ctxfi/ctamixer.c4
-rw-r--r--sound/pci/ctxfi/ctdaio.c4
-rw-r--r--sound/pci/ctxfi/ctsrc.c4
-rw-r--r--sound/pci/ctxfi/cttimer.c2
-rw-r--r--sound/pci/emu10k1/emufx.c2
-rw-r--r--sound/soc/codecs/simple-amplifier.c2
-rw-r--r--sound/soc/generic/simple-card-utils.c2
-rw-r--r--sound/soc/meson/gx-formatter.c2
-rw-r--r--sound/soc/qcom/qdsp6/q6afe.c2
-rw-r--r--sound/soc/sdca/sdca_functions.c19
-rw-r--r--sound/soc/sof/sof-client-probes-ipc4.c2
-rw-r--r--sound/soc/sof/sof-client.c2
-rw-r--r--sound/sparc/amd7930.c2
27 files changed, 42 insertions, 43 deletions
diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
index 23d62fede06e..7c397b1c9231 100644
--- a/sound/core/compress_offload.c
+++ b/sound/core/compress_offload.c
@@ -107,7 +107,7 @@ static int snd_compr_open(struct inode *inode, struct file *f)
return -EINVAL;
}
- data = kzalloc(sizeof(*data), GFP_KERNEL);
+ data = kzalloc_obj(*data);
if (!data) {
snd_card_unref(compr->card);
return -ENOMEM;
@@ -119,7 +119,7 @@ static int snd_compr_open(struct inode *inode, struct file *f)
data->stream.direction = dirn;
data->stream.private_data = compr->private_data;
data->stream.device = compr;
- runtime = kzalloc(sizeof(*runtime), GFP_KERNEL);
+ runtime = kzalloc_obj(*runtime);
if (!runtime) {
kfree(data);
snd_card_unref(compr->card);
diff --git a/sound/core/control.c b/sound/core/control.c
index 78ce7bc936d2..4199342d4ffe 100644
--- a/sound/core/control.c
+++ b/sound/core/control.c
@@ -69,7 +69,7 @@ static int snd_ctl_open(struct inode *inode, struct file *file)
err = -ENODEV;
goto __error2;
}
- ctl = kzalloc(sizeof(*ctl), GFP_KERNEL);
+ ctl = kzalloc_obj(*ctl);
if (ctl == NULL) {
err = -ENOMEM;
goto __error;
@@ -174,7 +174,7 @@ void snd_ctl_notify(struct snd_card *card, unsigned int mask,
goto _found;
}
}
- ev = kzalloc(sizeof(*ev), GFP_ATOMIC);
+ ev = kzalloc_obj(*ev, GFP_ATOMIC);
if (ev) {
ev->id = *id;
ev->mask = mask;
@@ -871,7 +871,7 @@ static int snd_ctl_card_info(struct snd_card *card, struct snd_ctl_file * ctl,
unsigned int cmd, void __user *arg)
{
struct snd_ctl_card_info *info __free(kfree) =
- kzalloc(sizeof(*info), GFP_KERNEL);
+ kzalloc_obj(*info);
ssize_t n;
if (! info)
diff --git a/sound/core/control_led.c b/sound/core/control_led.c
index 3d13bbec1c54..ec0e6c7ad657 100644
--- a/sound/core/control_led.c
+++ b/sound/core/control_led.c
@@ -158,7 +158,7 @@ static void snd_ctl_led_set_state(struct snd_card *card, unsigned int access,
UPDATE_ROUTE(route, snd_ctl_led_get(lctl));
}
if (!found && kctl && card) {
- lctl = kzalloc(sizeof(*lctl), GFP_KERNEL);
+ lctl = kzalloc_obj(*lctl);
if (lctl) {
lctl->card = card;
lctl->access = access;
diff --git a/sound/core/init.c b/sound/core/init.c
index 2f7f83a7611b..9693e646b3bb 100644
--- a/sound/core/init.c
+++ b/sound/core/init.c
@@ -364,7 +364,7 @@ static int snd_card_init(struct snd_card *card, struct device *parent,
sound_debugfs_root);
#endif
#ifdef CONFIG_SND_CTL_DEBUG
- card->value_buf = kmalloc(sizeof(*card->value_buf), GFP_KERNEL);
+ card->value_buf = kmalloc_obj(*card->value_buf);
if (!card->value_buf)
return -ENOMEM;
#endif
diff --git a/sound/core/misc.c b/sound/core/misc.c
index 4772b2a3b808..066fb9ecdcdc 100644
--- a/sound/core/misc.c
+++ b/sound/core/misc.c
@@ -125,7 +125,7 @@ int snd_fasync_helper(int fd, struct file *file, int on,
struct snd_fasync *fasync = NULL;
if (on) {
- fasync = kzalloc(sizeof(*fasync), GFP_KERNEL);
+ fasync = kzalloc_obj(*fasync);
if (!fasync)
return -ENOMEM;
INIT_LIST_HEAD(&fasync->list);
diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c
index ff9d7fd60a7e..c533d767c29a 100644
--- a/sound/core/oss/mixer_oss.c
+++ b/sound/core/oss/mixer_oss.c
@@ -890,7 +890,7 @@ static int snd_mixer_oss_build_test(struct snd_mixer_oss *mixer, struct slot *sl
int err;
struct snd_ctl_elem_info *info __free(kfree) =
- kmalloc(sizeof(*info), GFP_KERNEL);
+ kmalloc_obj(*info);
if (!info)
return -ENOMEM;
scoped_guard(rwsem_read, &card->controls_rwsem) {
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 62324282fcae..6d32c12fb79b 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -2330,7 +2330,7 @@ static int snd_pcm_link(struct snd_pcm_substream *substream, int fd)
return -EINVAL;
struct snd_pcm_group *group __free(kfree) =
- kzalloc(sizeof(*group), GFP_KERNEL);
+ kzalloc_obj(*group);
if (!group)
return -ENOMEM;
snd_pcm_group_init(group);
diff --git a/sound/core/seq/oss/seq_oss_synth.c b/sound/core/seq/oss/seq_oss_synth.c
index c4b82e29ab05..21a0a98c8e92 100644
--- a/sound/core/seq/oss/seq_oss_synth.c
+++ b/sound/core/seq/oss/seq_oss_synth.c
@@ -86,7 +86,7 @@ snd_seq_oss_synth_probe(struct snd_seq_device *dev)
struct seq_oss_synth *rec;
struct snd_seq_oss_reg *reg = SNDRV_SEQ_DEVICE_ARGPTR(dev);
- rec = kzalloc(sizeof(*rec), GFP_KERNEL);
+ rec = kzalloc_obj(*rec);
if (!rec)
return -ENOMEM;
rec->seq_device = -1;
diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c
index 5b86e75c2658..239809ce48d7 100644
--- a/sound/core/seq/seq_clientmgr.c
+++ b/sound/core/seq/seq_clientmgr.c
@@ -210,7 +210,7 @@ static struct snd_seq_client *seq_create_client1(int client_index, int poolsize)
struct snd_seq_client *client;
/* init client data */
- client = kzalloc(sizeof(*client), GFP_KERNEL);
+ client = kzalloc_obj(*client);
if (client == NULL)
return NULL;
client->pool = snd_seq_pool_new(poolsize);
diff --git a/sound/core/seq/seq_virmidi.c b/sound/core/seq/seq_virmidi.c
index 6208bf7f57bf..a01785a6de9b 100644
--- a/sound/core/seq/seq_virmidi.c
+++ b/sound/core/seq/seq_virmidi.c
@@ -188,7 +188,7 @@ static int snd_virmidi_input_open(struct snd_rawmidi_substream *substream)
struct snd_rawmidi_runtime *runtime = substream->runtime;
struct snd_virmidi *vmidi;
- vmidi = kzalloc(sizeof(*vmidi), GFP_KERNEL);
+ vmidi = kzalloc_obj(*vmidi);
if (vmidi == NULL)
return -ENOMEM;
vmidi->substream = substream;
diff --git a/sound/core/timer.c b/sound/core/timer.c
index f666f05e9d45..679b26435670 100644
--- a/sound/core/timer.c
+++ b/sound/core/timer.c
@@ -1855,7 +1855,7 @@ static int snd_timer_user_info(struct file *file,
return -EBADFD;
struct snd_timer_info *info __free(kfree) =
- kzalloc(sizeof(*info), GFP_KERNEL);
+ kzalloc_obj(*info);
if (! info)
return -ENOMEM;
info->card = t->card ? t->card->number : -1;
diff --git a/sound/drivers/aloop.c b/sound/drivers/aloop.c
index 4e3ea23ca913..81cb1f59f703 100644
--- a/sound/drivers/aloop.c
+++ b/sound/drivers/aloop.c
@@ -1365,7 +1365,7 @@ static int loopback_open(struct snd_pcm_substream *substream)
int dev = get_cable_index(substream);
guard(mutex)(&loopback->cable_lock);
- dpcm = kzalloc(sizeof(*dpcm), GFP_KERNEL);
+ dpcm = kzalloc_obj(*dpcm);
if (!dpcm)
return -ENOMEM;
dpcm->loopback = loopback;
@@ -1373,7 +1373,7 @@ static int loopback_open(struct snd_pcm_substream *substream)
cable = loopback->cables[substream->number][dev];
if (!cable) {
- cable = kzalloc(sizeof(*cable), GFP_KERNEL);
+ cable = kzalloc_obj(*cable);
if (!cable) {
err = -ENOMEM;
goto unlock;
diff --git a/sound/isa/gus/gus_dma.c b/sound/isa/gus/gus_dma.c
index 30bd76eee96e..7be6ff201ecb 100644
--- a/sound/isa/gus/gus_dma.c
+++ b/sound/isa/gus/gus_dma.c
@@ -214,7 +214,7 @@ int snd_gf1_dma_transfer_block(struct snd_gus_card * gus,
struct snd_gf1_dma_block *block;
struct snd_gf1_dma_block *free_block = NULL;
- block = kmalloc(sizeof(*block), atomic ? GFP_ATOMIC : GFP_KERNEL);
+ block = kmalloc_obj(*block, atomic ? GFP_ATOMIC : GFP_KERNEL);
if (!block)
return -ENOMEM;
diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c
index 19a6927c079d..f6db08b75649 100644
--- a/sound/pci/cs46xx/cs46xx_lib.c
+++ b/sound/pci/cs46xx/cs46xx_lib.c
@@ -1444,7 +1444,7 @@ static int _cs46xx_playback_open_channel (struct snd_pcm_substream *substream,in
struct snd_cs46xx_pcm * cpcm;
struct snd_pcm_runtime *runtime = substream->runtime;
- cpcm = kzalloc(sizeof(*cpcm), GFP_KERNEL);
+ cpcm = kzalloc_obj(*cpcm);
if (cpcm == NULL)
return -ENOMEM;
if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &chip->pci->dev,
diff --git a/sound/pci/ctxfi/ctamixer.c b/sound/pci/ctxfi/ctamixer.c
index 5fc1c922620a..f356917cb6ac 100644
--- a/sound/pci/ctxfi/ctamixer.c
+++ b/sound/pci/ctxfi/ctamixer.c
@@ -236,7 +236,7 @@ static int get_amixer_rsc(struct amixer_mgr *mgr,
*ramixer = NULL;
/* Allocate mem for amixer resource */
- amixer = kzalloc(sizeof(*amixer), GFP_KERNEL);
+ amixer = kzalloc_obj(*amixer);
if (!amixer)
return -ENOMEM;
@@ -390,7 +390,7 @@ static int get_sum_rsc(struct sum_mgr *mgr,
*rsum = NULL;
/* Allocate mem for sum resource */
- sum = kzalloc(sizeof(*sum), GFP_KERNEL);
+ sum = kzalloc_obj(*sum);
if (!sum)
return -ENOMEM;
diff --git a/sound/pci/ctxfi/ctdaio.c b/sound/pci/ctxfi/ctdaio.c
index 69aacd06716c..9be70c6862ab 100644
--- a/sound/pci/ctxfi/ctdaio.c
+++ b/sound/pci/ctxfi/ctdaio.c
@@ -540,7 +540,7 @@ static int get_daio_rsc(struct daio_mgr *mgr,
err = -ENOMEM;
/* Allocate mem for daio resource */
if (desc->output) {
- struct dao *dao = kzalloc(sizeof(*dao), GFP_KERNEL);
+ struct dao *dao = kzalloc_obj(*dao);
if (!dao)
goto error;
@@ -552,7 +552,7 @@ static int get_daio_rsc(struct daio_mgr *mgr,
*rdaio = &dao->daio;
} else {
- struct dai *dai = kzalloc(sizeof(*dai), GFP_KERNEL);
+ struct dai *dai = kzalloc_obj(*dai);
if (!dai)
goto error;
diff --git a/sound/pci/ctxfi/ctsrc.c b/sound/pci/ctxfi/ctsrc.c
index 46dc1f509234..1fadaf22309f 100644
--- a/sound/pci/ctxfi/ctsrc.c
+++ b/sound/pci/ctxfi/ctsrc.c
@@ -432,9 +432,9 @@ get_src_rsc(struct src_mgr *mgr, const struct src_desc *desc, struct src **rsrc)
/* Allocate mem for master src resource */
if (MEMRD == desc->mode)
- src = kcalloc(desc->multi, sizeof(*src), GFP_KERNEL);
+ src = kzalloc_objs(*src, desc->multi);
else
- src = kzalloc(sizeof(*src), GFP_KERNEL);
+ src = kzalloc_obj(*src);
if (!src) {
err = -ENOMEM;
diff --git a/sound/pci/ctxfi/cttimer.c b/sound/pci/ctxfi/cttimer.c
index cc379d880cad..9d6f5df2bc7e 100644
--- a/sound/pci/ctxfi/cttimer.c
+++ b/sound/pci/ctxfi/cttimer.c
@@ -318,7 +318,7 @@ ct_timer_instance_new(struct ct_timer *atimer, struct ct_atc_pcm *apcm)
{
struct ct_timer_instance *ti;
- ti = kzalloc(sizeof(*ti), GFP_KERNEL);
+ ti = kzalloc_obj(*ti);
if (!ti)
return NULL;
spin_lock_init(&ti->lock);
diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c
index 49cabb2eb2b7..a33817aba17f 100644
--- a/sound/pci/emu10k1/emufx.c
+++ b/sound/pci/emu10k1/emufx.c
@@ -2470,7 +2470,7 @@ static int snd_emu10k1_fx8010_ioctl(struct snd_hwdep * hw, struct file *file, un
emu->support_tlv = 1;
return put_user(SNDRV_EMU10K1_VERSION, (int __user *)argp);
case SNDRV_EMU10K1_IOCTL_INFO:
- info = kzalloc(sizeof(*info), GFP_KERNEL);
+ info = kzalloc_obj(*info, GFP_KERNEL);
if (!info)
return -ENOMEM;
snd_emu10k1_fx8010_info(emu, info);
diff --git a/sound/soc/codecs/simple-amplifier.c b/sound/soc/codecs/simple-amplifier.c
index ca53b08c0b33..07c040355c37 100644
--- a/sound/soc/codecs/simple-amplifier.c
+++ b/sound/soc/codecs/simple-amplifier.c
@@ -371,7 +371,7 @@ static unsigned int *simple_amp_alloc_tlv_ranges(const struct simple_amp_ranges
unsigned int *t;
unsigned int i;
- tlv = kzalloc_objs(*tlv, 2 + ranges->nb_ranges * 6, GFP_KERNEL);
+ tlv = kzalloc_objs(*tlv, 2 + ranges->nb_ranges * 6);
if (!tlv)
return NULL;
diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c
index 42019daa5e04..5f3423129b13 100644
--- a/sound/soc/generic/simple-card-utils.c
+++ b/sound/soc/generic/simple-card-utils.c
@@ -168,7 +168,7 @@ int simple_util_parse_tdm_width_map(struct simple_util_priv *priv, struct device
if (!dai->tdm_width_map)
return simple_ret(priv, ret); /* see NOTE */
- u32 *array_values __free(kfree) = kcalloc(n, sizeof(*array_values), GFP_KERNEL);
+ u32 *array_values __free(kfree) = kzalloc_objs(*array_values, n);
if (!array_values)
goto end;
diff --git a/sound/soc/meson/gx-formatter.c b/sound/soc/meson/gx-formatter.c
index 311e63affb23..2d3218cce426 100644
--- a/sound/soc/meson/gx-formatter.c
+++ b/sound/soc/meson/gx-formatter.c
@@ -253,7 +253,7 @@ struct gx_stream *gx_stream_alloc(struct gx_iface *iface)
{
struct gx_stream *ts;
- ts = kzalloc(sizeof(*ts), GFP_KERNEL);
+ ts = kzalloc_obj(*ts);
if (ts) {
INIT_LIST_HEAD(&ts->formatter_list);
mutex_init(&ts->lock);
diff --git a/sound/soc/qcom/qdsp6/q6afe.c b/sound/soc/qcom/qdsp6/q6afe.c
index 1d68a80e8e0c..f0ff1350e9dd 100644
--- a/sound/soc/qcom/qdsp6/q6afe.c
+++ b/sound/soc/qcom/qdsp6/q6afe.c
@@ -1857,7 +1857,7 @@ struct q6afe_port *q6afe_port_get_from_id(struct device *dev, int id)
return ERR_PTR(-EINVAL);
}
- port = kzalloc(sizeof(*port), GFP_KERNEL);
+ port = kzalloc_obj(*port, GFP_KERNEL);
if (!port)
return ERR_PTR(-ENOMEM);
diff --git a/sound/soc/sdca/sdca_functions.c b/sound/soc/sdca/sdca_functions.c
index e01d91eb3cc8..32d9b7f30a4f 100644
--- a/sound/soc/sdca/sdca_functions.c
+++ b/sound/soc/sdca/sdca_functions.c
@@ -1249,8 +1249,7 @@ static int find_sdca_entity_pde(struct device *dev,
return -EINVAL;
}
- u32 *delay_list __free(kfree) = kcalloc(num_delays, sizeof(*delay_list),
- GFP_KERNEL);
+ u32 *delay_list __free(kfree) = kzalloc_objs(*delay_list, num_delays);
if (!delay_list)
return -ENOMEM;
@@ -1313,8 +1312,8 @@ static int find_sdca_entity_ge(struct device *dev,
return -EINVAL;
}
- u8 *affected_list __free(kfree) = kcalloc(num_affected, sizeof(*affected_list),
- GFP_KERNEL);
+ u8 *affected_list __free(kfree) = kzalloc_objs(*affected_list,
+ num_affected);
if (!affected_list)
return -ENOMEM;
@@ -1552,8 +1551,8 @@ static int find_sdca_entities(struct device *dev, struct fwnode_handle *function
if (!entities)
return -ENOMEM;
- u32 *entity_list __free(kfree) = kcalloc(num_entities, sizeof(*entity_list),
- GFP_KERNEL);
+ u32 *entity_list __free(kfree) = kzalloc_objs(*entity_list,
+ num_entities);
if (!entity_list)
return -ENOMEM;
@@ -1715,8 +1714,8 @@ static int find_sdca_entity_connection_pde(struct device *dev,
if (!managed)
return -ENOMEM;
- u32 *managed_list __free(kfree) = kcalloc(num_managed, sizeof(*managed_list),
- GFP_KERNEL);
+ u32 *managed_list __free(kfree) = kzalloc_objs(*managed_list,
+ num_managed);
if (!managed_list)
return -ENOMEM;
@@ -2033,8 +2032,8 @@ static int find_sdca_clusters(struct device *dev,
if (!clusters)
return -ENOMEM;
- u32 *cluster_list __free(kfree) = kcalloc(num_clusters, sizeof(*cluster_list),
- GFP_KERNEL);
+ u32 *cluster_list __free(kfree) = kzalloc_objs(*cluster_list,
+ num_clusters);
if (!cluster_list)
return -ENOMEM;
diff --git a/sound/soc/sof/sof-client-probes-ipc4.c b/sound/soc/sof/sof-client-probes-ipc4.c
index 2eef32b55395..c547ea61fb3d 100644
--- a/sound/soc/sof/sof-client-probes-ipc4.c
+++ b/sound/soc/sof/sof-client-probes-ipc4.c
@@ -260,7 +260,7 @@ static int ipc4_probes_points_info(struct sof_client_dev *cdev,
*num_desc = info->num_elems;
dev_dbg(dev, "%s: got %zu probe points", __func__, *num_desc);
- *desc = kcalloc(*num_desc, sizeof(**desc), GFP_KERNEL);
+ *desc = kzalloc_objs(**desc, *num_desc);
if (!*desc) {
kfree(msg.data_ptr);
return -ENOMEM;
diff --git a/sound/soc/sof/sof-client.c b/sound/soc/sof/sof-client.c
index c7bbf09e547f..64da8df15bf2 100644
--- a/sound/soc/sof/sof-client.c
+++ b/sound/soc/sof/sof-client.c
@@ -230,7 +230,7 @@ int sof_client_dev_register(struct snd_sof_dev *sdev, const char *name, u32 id,
struct sof_client_dev *cdev;
int ret;
- centry = kzalloc(sizeof(*centry), GFP_KERNEL);
+ centry = kzalloc_obj(*centry);
if (!centry)
return -ENOMEM;
diff --git a/sound/sparc/amd7930.c b/sound/sparc/amd7930.c
index da04ed5cbac4..d746b2586d88 100644
--- a/sound/sparc/amd7930.c
+++ b/sound/sparc/amd7930.c
@@ -903,7 +903,7 @@ static int snd_amd7930_create(struct snd_card *card,
int err;
*ramd = NULL;
- amd = kzalloc(sizeof(*amd), GFP_KERNEL);
+ amd = kzalloc_obj(*amd);
if (amd == NULL)
return -ENOMEM;