]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
ASoC: SOF: ipc4-pcm: Adjust pipeline_list->pipelines allocation type
authorKees Cook <kees@kernel.org>
Sat, 26 Apr 2025 06:25:12 +0000 (23:25 -0700)
committerMark Brown <broonie@kernel.org>
Wed, 30 Apr 2025 00:38:23 +0000 (09:38 +0900)
In preparation for making the kmalloc family of allocators type aware,
we need to make sure that the returned type from the allocation matches
the type of the variable being assigned. (Before, the allocator would
always return "void *", which can be implicitly cast to any pointer type.)

The assigned type is "struct snd_sof_pipeline **", but the returned type
will be "struct snd_sof_widget **". These are the same size allocation
(pointer size) but the types don't match. Adjust the allocation type to
match the assignment.

Signed-off-by: Kees Cook <kees@kernel.org>
Fixes: 9c04363d222b ("ASoC: SOF: Introduce struct snd_sof_pipeline")
Acked-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://patch.msgid.link/20250426062511.work.859-kees@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sof/ipc4-pcm.c

index 1a2841899ff5a9b7d9e54ddbff3f1b803c2520f1..52903503cf3b831774f9bb0100e6373d9a4b5d2f 100644 (file)
@@ -784,7 +784,8 @@ static int sof_ipc4_pcm_setup(struct snd_sof_dev *sdev, struct snd_sof_pcm *spcm
 
                /* allocate memory for max number of pipeline IDs */
                pipeline_list->pipelines = kcalloc(ipc4_data->max_num_pipelines,
-                                                  sizeof(struct snd_sof_widget *), GFP_KERNEL);
+                                                  sizeof(*pipeline_list->pipelines),
+                                                  GFP_KERNEL);
                if (!pipeline_list->pipelines) {
                        sof_ipc4_pcm_free(sdev, spcm);
                        return -ENOMEM;