Skip to content

Commit 90f3feb

Browse files
Revaliolibroonie
authored andcommitted
ASoC: fsl-asoc-card: set priv->pdev before using it
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: 708b435 ("ASoC: fsl: Add Freescale Generic ASoC Sound Card with ASRC support") Signed-off-by: Elinor Montmasson <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 379bcd2 commit 90f3feb

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

sound/soc/fsl/fsl-asoc-card.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,8 @@ static int fsl_asoc_card_probe(struct platform_device *pdev)
559559
if (!priv)
560560
return -ENOMEM;
561561

562+
priv->pdev = pdev;
563+
562564
cpu_np = of_parse_phandle(np, "audio-cpu", 0);
563565
/* Give a chance to old DT binding */
564566
if (!cpu_np)
@@ -787,7 +789,6 @@ static int fsl_asoc_card_probe(struct platform_device *pdev)
787789
}
788790

789791
/* Initialize sound card */
790-
priv->pdev = pdev;
791792
priv->card.dev = &pdev->dev;
792793
priv->card.owner = THIS_MODULE;
793794
ret = snd_soc_of_parse_card_name(&priv->card, "model");

0 commit comments

Comments
 (0)