* [PATCH] ASoC: SOF: imx-common: set sdev->pdata->hw_pdata after common is alloc'd
@ 2025-02-11 22:50 Laurentiu Mihalcea
2025-02-11 23:25 ` Frank Li
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Laurentiu Mihalcea @ 2025-02-11 22:50 UTC (permalink / raw)
To: Mark Brown, Peter Ujfalusi, Bard Liao, Daniel Baluta
Cc: imx, linux-sound, linux-kernel
From: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.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@nxp.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
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] ASoC: SOF: imx-common: set sdev->pdata->hw_pdata after common is alloc'd
2025-02-11 22:50 [PATCH] ASoC: SOF: imx-common: set sdev->pdata->hw_pdata after common is alloc'd Laurentiu Mihalcea
@ 2025-02-11 23:25 ` Frank Li
2025-02-12 9:22 ` Daniel Baluta
2025-02-13 13:41 ` Mark Brown
2 siblings, 0 replies; 4+ messages in thread
From: Frank Li @ 2025-02-11 23:25 UTC (permalink / raw)
To: Laurentiu Mihalcea
Cc: Mark Brown, Peter Ujfalusi, Bard Liao, Daniel Baluta, imx,
linux-sound, linux-kernel
On Tue, Feb 11, 2025 at 05:50:18PM -0500, Laurentiu Mihalcea wrote:
> From: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.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@nxp.com>
Reviewed-by: Frank Li <Frank.Li@nxp.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
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ASoC: SOF: imx-common: set sdev->pdata->hw_pdata after common is alloc'd
2025-02-11 22:50 [PATCH] ASoC: SOF: imx-common: set sdev->pdata->hw_pdata after common is alloc'd Laurentiu Mihalcea
2025-02-11 23:25 ` Frank Li
@ 2025-02-12 9:22 ` Daniel Baluta
2025-02-13 13:41 ` Mark Brown
2 siblings, 0 replies; 4+ messages in thread
From: Daniel Baluta @ 2025-02-12 9:22 UTC (permalink / raw)
To: Laurentiu Mihalcea
Cc: Mark Brown, Peter Ujfalusi, Bard Liao, Daniel Baluta, imx,
linux-sound, linux-kernel
On Wed, Feb 12, 2025 at 12:50 AM Laurentiu Mihalcea
<laurentiumihalcea111@gmail.com> wrote:
>
> From: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.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@nxp.com>
Fixes: 651e0ed391b1 (" ASoC: SOF: imx: introduce more common
structures and functions")
Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] ASoC: SOF: imx-common: set sdev->pdata->hw_pdata after common is alloc'd
2025-02-11 22:50 [PATCH] ASoC: SOF: imx-common: set sdev->pdata->hw_pdata after common is alloc'd Laurentiu Mihalcea
2025-02-11 23:25 ` Frank Li
2025-02-12 9:22 ` Daniel Baluta
@ 2025-02-13 13:41 ` Mark Brown
2 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2025-02-13 13:41 UTC (permalink / raw)
To: Peter Ujfalusi, Bard Liao, Daniel Baluta, Laurentiu Mihalcea
Cc: imx, linux-sound, linux-kernel
On Tue, 11 Feb 2025 17:50:18 -0500, Laurentiu Mihalcea wrote:
> '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.
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/1] ASoC: SOF: imx-common: set sdev->pdata->hw_pdata after common is alloc'd
commit: f22ba3561daa792dd138ed543e0bf48efe0b999c
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-02-13 13:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-11 22:50 [PATCH] ASoC: SOF: imx-common: set sdev->pdata->hw_pdata after common is alloc'd Laurentiu Mihalcea
2025-02-11 23:25 ` Frank Li
2025-02-12 9:22 ` Daniel Baluta
2025-02-13 13:41 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®