* [PATCH] ASoC: q6dsp: q6apm: change kzalloc to kcalloc
@ 2025-01-20 1:32 Ethan Carter Edwards
2025-02-09 3:43 ` Ethan Carter Edwards
2025-02-09 10:15 ` Markus Elfring
0 siblings, 2 replies; 3+ messages in thread
From: Ethan Carter Edwards @ 2025-01-20 1:32 UTC (permalink / raw)
To: Srinivas Kandagatla
Cc: linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org,
kernel-hardening@lists.openwall.com, linux-sound, linux-arm-msm,
Takashi Iwai
We are replacing any instances of kzalloc(size * count, ...) with
kcalloc(count, size, ...) due to risk of overflow [1].
[1] https://www.kernel.org/doc/html/next/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments
Link: https://github.com/KSPP/linux/issues/162
Signed-off-by: Ethan Carter Edwards <ethan@ethancedwards.com>
---
sound/soc/qcom/qdsp6/q6apm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/qcom/qdsp6/q6apm.c b/sound/soc/qcom/qdsp6/q6apm.c
index 2a2a5bd98110..11e252a70f69 100644
--- a/sound/soc/qcom/qdsp6/q6apm.c
+++ b/sound/soc/qcom/qdsp6/q6apm.c
@@ -230,7 +230,7 @@ int q6apm_map_memory_regions(struct q6apm_graph *graph, unsigned int dir, phys_a
return 0;
}
- buf = kzalloc(((sizeof(struct audio_buffer)) * periods), GFP_KERNEL);
+ buf = kcalloc(periods, sizeof(struct audio_buffer), GFP_KERNEL);
if (!buf) {
mutex_unlock(&graph->lock);
return -ENOMEM;
--
2.48.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ASoC: q6dsp: q6apm: change kzalloc to kcalloc
2025-01-20 1:32 [PATCH] ASoC: q6dsp: q6apm: change kzalloc to kcalloc Ethan Carter Edwards
@ 2025-02-09 3:43 ` Ethan Carter Edwards
2025-02-09 10:15 ` Markus Elfring
1 sibling, 0 replies; 3+ messages in thread
From: Ethan Carter Edwards @ 2025-02-09 3:43 UTC (permalink / raw)
To: Srinivas Kandagatla
Cc: linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org,
kernel-hardening@lists.openwall.com, linux-sound, linux-arm-msm,
Takashi Iwai
I wanted to check in on this. Anything I need to change?
Thanks,
Ethan
On 25/01/19 08:32PM, Ethan Carter Edwards wrote:
> We are replacing any instances of kzalloc(size * count, ...) with
> kcalloc(count, size, ...) due to risk of overflow [1].
>
> [1] https://www.kernel.org/doc/html/next/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments
> Link: https://github.com/KSPP/linux/issues/162
>
> Signed-off-by: Ethan Carter Edwards <ethan@ethancedwards.com>
> ---
> sound/soc/qcom/qdsp6/q6apm.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/sound/soc/qcom/qdsp6/q6apm.c b/sound/soc/qcom/qdsp6/q6apm.c
> index 2a2a5bd98110..11e252a70f69 100644
> --- a/sound/soc/qcom/qdsp6/q6apm.c
> +++ b/sound/soc/qcom/qdsp6/q6apm.c
> @@ -230,7 +230,7 @@ int q6apm_map_memory_regions(struct q6apm_graph *graph, unsigned int dir, phys_a
> return 0;
> }
>
> - buf = kzalloc(((sizeof(struct audio_buffer)) * periods), GFP_KERNEL);
> + buf = kcalloc(periods, sizeof(struct audio_buffer), GFP_KERNEL);
> if (!buf) {
> mutex_unlock(&graph->lock);
> return -ENOMEM;
> --
> 2.48.0
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ASoC: q6dsp: q6apm: change kzalloc to kcalloc
2025-01-20 1:32 [PATCH] ASoC: q6dsp: q6apm: change kzalloc to kcalloc Ethan Carter Edwards
2025-02-09 3:43 ` Ethan Carter Edwards
@ 2025-02-09 10:15 ` Markus Elfring
1 sibling, 0 replies; 3+ messages in thread
From: Markus Elfring @ 2025-02-09 10:15 UTC (permalink / raw)
To: Ethan Carter Edwards, kernel-hardening, linux-hardening,
linux-sound, linux-arm-msm, Srinivas Kandagatla
Cc: LKML, Takashi Iwai
> We are replacing any instances of kzalloc(size * count, ...) with
> kcalloc(count, size, ...) due to risk of overflow [1].
See also:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.13#n94
…
> +++ b/sound/soc/qcom/qdsp6/q6apm.c
> @@ -230,7 +230,7 @@ int q6apm_map_memory_regions(struct q6apm_graph *graph, unsigned int dir, phys_a
> return 0;
> }
>
> - buf = kzalloc(((sizeof(struct audio_buffer)) * periods), GFP_KERNEL);
> + buf = kcalloc(periods, sizeof(struct audio_buffer), GFP_KERNEL);
…
See also:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?h=v6.13#n941
How do you think about to increase the application of scope-based resource management?
Regards,
Markus
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-02-09 10:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-20 1:32 [PATCH] ASoC: q6dsp: q6apm: change kzalloc to kcalloc Ethan Carter Edwards
2025-02-09 3:43 ` Ethan Carter Edwards
2025-02-09 10:15 ` Markus Elfring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).