ASoC: fsl-asoc-card: set priv->pdev before using it
[ Upstream commit90f3feb241
] 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:708b4351f0
("ASoC: fsl: Add Freescale Generic ASoC Sound Card with ASRC support") Signed-off-by: Elinor Montmasson <elinor.montmasson@savoirfairelinux.com> Link: https://patch.msgid.link/20240620132511.4291-2-elinor.montmasson@savoirfairelinux.com Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
20f19c91da
commit
8faf91e584
@ -545,6 +545,8 @@ static int fsl_asoc_card_probe(struct platform_device *pdev)
|
||||
if (!priv)
|
||||
return -ENOMEM;
|
||||
|
||||
priv->pdev = pdev;
|
||||
|
||||
cpu_np = of_parse_phandle(np, "audio-cpu", 0);
|
||||
/* Give a chance to old DT binding */
|
||||
if (!cpu_np)
|
||||
@ -754,7 +756,6 @@ static int fsl_asoc_card_probe(struct platform_device *pdev)
|
||||
}
|
||||
|
||||
/* Initialize sound card */
|
||||
priv->pdev = pdev;
|
||||
priv->card.dev = &pdev->dev;
|
||||
priv->card.owner = THIS_MODULE;
|
||||
ret = snd_soc_of_parse_card_name(&priv->card, "model");
|
||||
|
Reference in New Issue
Block a user