Skip to content

Commit f22ba35

Browse files
LaurentiuM1234broonie
authored andcommitted
ASoC: SOF: imx-common: set sdev->pdata->hw_pdata after common is alloc'd
'imx_unregister_action' uses 'sdev->pdata->hw_pdata' to fetch the pointer to the common data structure. As such, if 'sdev->pdata->hw_pdata' is not set before adding 'imx_unregister_action' to the devres list, we risk derefrencing a NULL pointer if any of the calls between 'devm_add_action_or_reset' and 'sdev->pdata->hw_pdata = common' fails. Set 'sdev->pdata->hw_pdata' to point to 'common' as soon as 'common' is allocated. Fixes: 651e0ed (" ASoC: SOF: imx: introduce more common structures and functions") Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com> Reviewed-by: Frank Li <Frank.Li@nxp.com> Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com> Link: https://patch.msgid.link/20250211225018.2642-1-laurentiumihalcea111@gmail.com Reviewed-by: Frank Li <Frank.Li@nxp.com> Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 21aa330 commit f22ba35

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

sound/soc/sof/imx/imx-common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ static int imx_probe(struct snd_sof_dev *sdev)
378378
if (!common)
379379
return dev_err_probe(sdev->dev, -ENOMEM,
380380
"failed to allocate common data\n");
381+
sdev->pdata->hw_pdata = common;
381382

382383
common->ipc_dev = platform_device_register_data(sdev->dev, "imx-dsp",
383384
PLATFORM_DEVID_NONE,
@@ -436,7 +437,6 @@ static int imx_probe(struct snd_sof_dev *sdev)
436437
imx_dsp_set_data(common->ipc_handle, sdev);
437438

438439
sdev->num_cores = 1;
439-
sdev->pdata->hw_pdata = common;
440440
sdev->mailbox_bar = SOF_FW_BLK_TYPE_SRAM;
441441
sdev->dsp_box.offset = get_chip_info(sdev)->ipc_info.boot_mbox_offset;
442442

0 commit comments

Comments
 (0)