ASoC: davinci-mcasp: Use a copy of pdata per instance during DT boot
authorPeter Ujfalusi <peter.ujfalusi@ti.com>
Thu, 2 Jun 2016 09:55:24 +0000 (12:55 +0300)
committerMark Brown <broonie@kernel.org>
Thu, 2 Jun 2016 09:58:19 +0000 (10:58 +0100)
Instead of modifying the static pdata struct per McASP instance we need to
allocate pdata for each McASP.
This way we can avoid configuration leakage from prior McASP to McASP
drivers probed at later time.

Reported-by: Misael Lopez Cruz <misael.lopez@ti.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/davinci/davinci-mcasp.c

index 237dc67002efbefd600f96bb76997d21890a8b9f..05c2d33aa74dd9273100c9e8edf1b00bb57d8e35 100644 (file)
@@ -1599,7 +1599,14 @@ static struct davinci_mcasp_pdata *davinci_mcasp_set_pdata_from_of(
                pdata = pdev->dev.platform_data;
                return pdata;
        } else if (match) {
-               pdata = (struct davinci_mcasp_pdata*) match->data;
+               pdata = devm_kmemdup(&pdev->dev, match->data, sizeof(*pdata),
+                                    GFP_KERNEL);
+               if (!pdata) {
+                       dev_err(&pdev->dev,
+                               "Failed to allocate memory for pdata\n");
+                       ret = -ENOMEM;
+                       return pdata;
+               }
        } else {
                /* control shouldn't reach here. something is wrong */
                ret = -EINVAL;