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/soc/amd | |
| parent | d39a1d7486d98668dd34aaa6732aad7977c45f5a (diff) | |
| download | lwn-69050f8d6d075dc01af7a5f2f550a8067510366f.tar.gz lwn-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/soc/amd')
| -rw-r--r-- | sound/soc/amd/acp-pcm-dma.c | 2 | ||||
| -rw-r--r-- | sound/soc/amd/acp/acp-platform.c | 2 | ||||
| -rw-r--r-- | sound/soc/amd/acp/acp-sdw-legacy-mach.c | 4 | ||||
| -rw-r--r-- | sound/soc/amd/acp/acp-sdw-sof-mach.c | 4 | ||||
| -rw-r--r-- | sound/soc/amd/ps/ps-pdm-dma.c | 2 | ||||
| -rw-r--r-- | sound/soc/amd/ps/ps-sdw-dma.c | 2 | ||||
| -rw-r--r-- | sound/soc/amd/raven/acp3x-pcm-dma.c | 2 | ||||
| -rw-r--r-- | sound/soc/amd/renoir/acp3x-pdm-dma.c | 2 | ||||
| -rw-r--r-- | sound/soc/amd/vangogh/acp5x-pcm-dma.c | 2 | ||||
| -rw-r--r-- | sound/soc/amd/yc/acp6x-pdm-dma.c | 2 |
10 files changed, 12 insertions, 12 deletions
diff --git a/sound/soc/amd/acp-pcm-dma.c b/sound/soc/amd/acp-pcm-dma.c index 897dde630022..19c09ba2b510 100644 --- a/sound/soc/amd/acp-pcm-dma.c +++ b/sound/soc/amd/acp-pcm-dma.c @@ -775,7 +775,7 @@ static int acp_dma_open(struct snd_soc_component *component, struct snd_pcm_runtime *runtime = substream->runtime; struct audio_drv_data *intr_data = dev_get_drvdata(component->dev); struct audio_substream_data *adata = - kzalloc(sizeof(struct audio_substream_data), GFP_KERNEL); + kzalloc_obj(struct audio_substream_data, GFP_KERNEL); if (!adata) return -ENOMEM; diff --git a/sound/soc/amd/acp/acp-platform.c b/sound/soc/amd/acp/acp-platform.c index b25ac5612808..66a30da4b801 100644 --- a/sound/soc/amd/acp/acp-platform.c +++ b/sound/soc/amd/acp/acp-platform.c @@ -196,7 +196,7 @@ static int acp_dma_open(struct snd_soc_component *component, struct snd_pcm_subs struct acp_stream *stream; int ret; - stream = kzalloc(sizeof(*stream), GFP_KERNEL); + stream = kzalloc_obj(*stream, GFP_KERNEL); if (!stream) return -ENOMEM; diff --git a/sound/soc/amd/acp/acp-sdw-legacy-mach.c b/sound/soc/amd/acp/acp-sdw-legacy-mach.c index c93fc0920a3e..c1c28fee0496 100644 --- a/sound/soc/amd/acp/acp-sdw-legacy-mach.c +++ b/sound/soc/amd/acp/acp-sdw-legacy-mach.c @@ -395,13 +395,13 @@ static int soc_card_dai_links_create(struct snd_soc_card *card) /* One per DAI link, worst case is a DAI link for every endpoint */ struct asoc_sdw_dailink *soc_dais __free(kfree) = - kcalloc(num_ends, sizeof(*soc_dais), GFP_KERNEL); + kzalloc_objs(*soc_dais, num_ends, GFP_KERNEL); if (!soc_dais) return -ENOMEM; /* One per endpoint, ie. each DAI on each codec/amp */ struct asoc_sdw_endpoint *soc_ends __free(kfree) = - kcalloc(num_ends, sizeof(*soc_ends), GFP_KERNEL); + kzalloc_objs(*soc_ends, num_ends, GFP_KERNEL); if (!soc_ends) return -ENOMEM; diff --git a/sound/soc/amd/acp/acp-sdw-sof-mach.c b/sound/soc/amd/acp/acp-sdw-sof-mach.c index da815b3f6389..3319f0996fe6 100644 --- a/sound/soc/amd/acp/acp-sdw-sof-mach.c +++ b/sound/soc/amd/acp/acp-sdw-sof-mach.c @@ -288,13 +288,13 @@ static int sof_card_dai_links_create(struct snd_soc_card *card) /* One per DAI link, worst case is a DAI link for every endpoint */ struct asoc_sdw_dailink *sof_dais __free(kfree) = - kcalloc(num_ends, sizeof(*sof_dais), GFP_KERNEL); + kzalloc_objs(*sof_dais, num_ends, GFP_KERNEL); if (!sof_dais) return -ENOMEM; /* One per endpoint, ie. each DAI on each codec/amp */ struct asoc_sdw_endpoint *sof_ends __free(kfree) = - kcalloc(num_ends, sizeof(*sof_ends), GFP_KERNEL); + kzalloc_objs(*sof_ends, num_ends, GFP_KERNEL); if (!sof_ends) return -ENOMEM; diff --git a/sound/soc/amd/ps/ps-pdm-dma.c b/sound/soc/amd/ps/ps-pdm-dma.c index 9cfbe05ad996..5a4ba65847fd 100644 --- a/sound/soc/amd/ps/ps-pdm-dma.c +++ b/sound/soc/amd/ps/ps-pdm-dma.c @@ -189,7 +189,7 @@ static int acp63_pdm_dma_open(struct snd_soc_component *component, runtime = substream->runtime; adata = dev_get_drvdata(component->dev); - pdm_data = kzalloc(sizeof(*pdm_data), GFP_KERNEL); + pdm_data = kzalloc_obj(*pdm_data, GFP_KERNEL); if (!pdm_data) return -EINVAL; diff --git a/sound/soc/amd/ps/ps-sdw-dma.c b/sound/soc/amd/ps/ps-sdw-dma.c index 5449323e2728..0c7af398de3a 100644 --- a/sound/soc/amd/ps/ps-sdw-dma.c +++ b/sound/soc/amd/ps/ps-sdw-dma.c @@ -318,7 +318,7 @@ static int acp63_sdw_dma_open(struct snd_soc_component *component, runtime = substream->runtime; cpu_dai = snd_soc_rtd_to_cpu(prtd, 0); amd_manager = snd_soc_dai_get_drvdata(cpu_dai); - stream = kzalloc(sizeof(*stream), GFP_KERNEL); + stream = kzalloc_obj(*stream, GFP_KERNEL); if (!stream) return -ENOMEM; diff --git a/sound/soc/amd/raven/acp3x-pcm-dma.c b/sound/soc/amd/raven/acp3x-pcm-dma.c index bb9ed52d744d..2716c4e18c1f 100644 --- a/sound/soc/amd/raven/acp3x-pcm-dma.c +++ b/sound/soc/amd/raven/acp3x-pcm-dma.c @@ -218,7 +218,7 @@ static int acp3x_dma_open(struct snd_soc_component *component, prtd = snd_soc_substream_to_rtd(substream); component = snd_soc_rtdcom_lookup(prtd, DRV_NAME); adata = dev_get_drvdata(component->dev); - i2s_data = kzalloc(sizeof(*i2s_data), GFP_KERNEL); + i2s_data = kzalloc_obj(*i2s_data, GFP_KERNEL); if (!i2s_data) return -EINVAL; diff --git a/sound/soc/amd/renoir/acp3x-pdm-dma.c b/sound/soc/amd/renoir/acp3x-pdm-dma.c index a560d06097d5..c2dd512118ad 100644 --- a/sound/soc/amd/renoir/acp3x-pdm-dma.c +++ b/sound/soc/amd/renoir/acp3x-pdm-dma.c @@ -211,7 +211,7 @@ static int acp_pdm_dma_open(struct snd_soc_component *component, runtime = substream->runtime; adata = dev_get_drvdata(component->dev); - pdm_data = kzalloc(sizeof(*pdm_data), GFP_KERNEL); + pdm_data = kzalloc_obj(*pdm_data, GFP_KERNEL); if (!pdm_data) return -EINVAL; diff --git a/sound/soc/amd/vangogh/acp5x-pcm-dma.c b/sound/soc/amd/vangogh/acp5x-pcm-dma.c index aa4726899434..c52d2bed5c6c 100644 --- a/sound/soc/amd/vangogh/acp5x-pcm-dma.c +++ b/sound/soc/amd/vangogh/acp5x-pcm-dma.c @@ -213,7 +213,7 @@ static int acp5x_dma_open(struct snd_soc_component *component, component = snd_soc_rtdcom_lookup(prtd, DRV_NAME); adata = dev_get_drvdata(component->dev); - i2s_data = kzalloc(sizeof(*i2s_data), GFP_KERNEL); + i2s_data = kzalloc_obj(*i2s_data, GFP_KERNEL); if (!i2s_data) return -ENOMEM; diff --git a/sound/soc/amd/yc/acp6x-pdm-dma.c b/sound/soc/amd/yc/acp6x-pdm-dma.c index ac758b90f441..b4fece9d3fac 100644 --- a/sound/soc/amd/yc/acp6x-pdm-dma.c +++ b/sound/soc/amd/yc/acp6x-pdm-dma.c @@ -187,7 +187,7 @@ static int acp6x_pdm_dma_open(struct snd_soc_component *component, runtime = substream->runtime; adata = dev_get_drvdata(component->dev); - pdm_data = kzalloc(sizeof(*pdm_data), GFP_KERNEL); + pdm_data = kzalloc_obj(*pdm_data, GFP_KERNEL); if (!pdm_data) return -EINVAL; |
