Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ae81535c authored by Elinor Montmasson's avatar Elinor Montmasson Committed by Greg Kroah-Hartman
Browse files

ASoC: fsl-asoc-card: set priv->pdev before using it



[ Upstream commit 90f3feb24172185f1832636264943e8b5e289245 ]

priv->pdev pointer was set after being used in
fsl_asoc_card_audmux_init().
Move this assignment at the start of the probe function, so
sub-functions can correctly use pdev through priv.

fsl_asoc_card_audmux_init() dereferences priv->pdev to get access to the
dev struct, used with dev_err macros.
As priv is zero-initialised, there would be a NULL pointer dereference.
Note that if priv->dev is dereferenced before assignment but never used,
for example if there is no error to be printed, the driver won't crash
probably due to compiler optimisations.

Fixes: 708b4351 ("ASoC: fsl: Add Freescale Generic ASoC Sound Card with ASRC support")
Signed-off-by: default avatarElinor Montmasson <elinor.montmasson@savoirfairelinux.com>
Link: https://patch.msgid.link/20240620132511.4291-2-elinor.montmasson@savoirfairelinux.com


Signed-off-by: default avatarMark Brown <broonie@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent f696eaf6
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -479,6 +479,8 @@ static int fsl_asoc_card_probe(struct platform_device *pdev)
	if (!priv)
	if (!priv)
		return -ENOMEM;
		return -ENOMEM;


	priv->pdev = pdev;

	cpu_np = of_parse_phandle(np, "audio-cpu", 0);
	cpu_np = of_parse_phandle(np, "audio-cpu", 0);
	/* Give a chance to old DT binding */
	/* Give a chance to old DT binding */
	if (!cpu_np)
	if (!cpu_np)
@@ -591,7 +593,6 @@ static int fsl_asoc_card_probe(struct platform_device *pdev)
		 codec_dev->name);
		 codec_dev->name);


	/* Initialize sound card */
	/* Initialize sound card */
	priv->pdev = pdev;
	priv->card.dev = &pdev->dev;
	priv->card.dev = &pdev->dev;
	priv->card.name = priv->name;
	priv->card.name = priv->name;
	priv->card.dai_link = priv->dai_link;
	priv->card.dai_link = priv->dai_link;