diff mbox

ASoC: Intel: mfld-pcm: Allocate platform data

Message ID 1406725745-30776-1-git-send-email-subhransu.s.prusty@intel.com (mailing list archive)
State Accepted
Commit 2741d43a1edd13c81a50ceb63f4edbf5fedb53ce
Headers show

Commit Message

Subhransu S. Prusty July 30, 2014, 1:09 p.m. UTC
Platform data may be null during platform_device_add. Allocate platform
data before using.

Signed-off-by: Subhransu S. Prusty <subhransu.s.prusty@intel.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
---
 sound/soc/intel/sst-mfld-platform-pcm.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Mark Brown July 31, 2014, 7:19 p.m. UTC | #1
On Wed, Jul 30, 2014 at 06:39:05PM +0530, Subhransu S. Prusty wrote:
> Platform data may be null during platform_device_add. Allocate platform
> data before using.

Applied, thanks.  Looking at the change I hope that "may" should be
"will" - this will unconditionally overwrite any platform data that's
there.
diff mbox

Patch

diff --git a/sound/soc/intel/sst-mfld-platform-pcm.c b/sound/soc/intel/sst-mfld-platform-pcm.c
index dbff2965a6e3..8dd1c0f6773f 100644
--- a/sound/soc/intel/sst-mfld-platform-pcm.c
+++ b/sound/soc/intel/sst-mfld-platform-pcm.c
@@ -694,7 +694,7 @@  static int sst_platform_probe(struct platform_device *pdev)
 {
 	struct sst_data *drv;
 	int ret;
-	struct sst_platform_data *pdata = pdev->dev.platform_data;
+	struct sst_platform_data *pdata;
 
 	drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_KERNEL);
 	if (drv == NULL) {
@@ -702,6 +702,12 @@  static int sst_platform_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	}
 
+	pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
+	if (pdata == NULL) {
+		pr_err("kzalloc failed for pdata\n");
+		return -ENOMEM;
+	}
+
 	pdata->pdev_strm_map = dpcm_strm_map;
 	pdata->strm_map_size = ARRAY_SIZE(dpcm_strm_map);
 	drv->pdata = pdata;