[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z6vcZVXcnM3C3hSh@lizhi-Precision-Tower-5810>
Date: Tue, 11 Feb 2025 18:25:25 -0500
From: Frank Li <Frank.li@....com>
To: Laurentiu Mihalcea <laurentiumihalcea111@...il.com>
Cc: Mark Brown <broonie@...nel.org>,
Peter Ujfalusi <peter.ujfalusi@...ux.intel.com>,
Bard Liao <yung-chuan.liao@...ux.intel.com>,
Daniel Baluta <daniel.baluta@....com>, imx@...ts.linux.dev,
linux-sound@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] ASoC: SOF: imx-common: set sdev->pdata->hw_pdata after
common is alloc'd
On Tue, Feb 11, 2025 at 05:50:18PM -0500, Laurentiu Mihalcea wrote:
> From: Laurentiu Mihalcea <laurentiu.mihalcea@....com>
>
> '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.
>
> Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@....com>
Reviewed-by: Frank Li <Frank.Li@....com>
> ---
> sound/soc/sof/imx/imx-common.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/sound/soc/sof/imx/imx-common.c b/sound/soc/sof/imx/imx-common.c
> index 82057af1436c..c3594815e60e 100644
> --- a/sound/soc/sof/imx/imx-common.c
> +++ b/sound/soc/sof/imx/imx-common.c
> @@ -378,6 +378,7 @@ static int imx_probe(struct snd_sof_dev *sdev)
> 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,
> @@ -436,7 +437,6 @@ static int imx_probe(struct snd_sof_dev *sdev)
> 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;
>
> --
> 2.34.1
>
Powered by blists - more mailing lists