'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: 651e0ed391b1 (" 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>
if (!common)
return dev_err_probe(sdev->dev, -ENOMEM,
"failed to allocate common data\n");
+ sdev->pdata->hw_pdata = common;
common->ipc_dev = platform_device_register_data(sdev->dev, "imx-dsp",
PLATFORM_DEVID_NONE,
imx_dsp_set_data(common->ipc_handle, sdev);
sdev->num_cores = 1;
- sdev->pdata->hw_pdata = common;
sdev->mailbox_bar = SOF_FW_BLK_TYPE_SRAM;
sdev->dsp_box.offset = get_chip_info(sdev)->ipc_info.boot_mbox_offset;