From: Peter Ujfalusi Date: Thu, 2 Jun 2016 09:55:24 +0000 (+0300) Subject: ASoC: davinci-mcasp: Use a copy of pdata per instance during DT boot X-Git-Tag: v4.8-rc1~84^2~1^2~8^5 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=272ee030ebc9da58a5796e6e26f78b77ecce7c21;p=karo-tx-linux.git ASoC: davinci-mcasp: Use a copy of pdata per instance during DT boot 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 Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c index 237dc67002ef..05c2d33aa74d 100644 --- a/sound/soc/davinci/davinci-mcasp.c +++ b/sound/soc/davinci/davinci-mcasp.c @@ -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;