ASoC: Intel: mfld-pcm: Allocate platform data
authorSubhransu S. Prusty <subhransu.s.prusty@intel.com>
Wed, 30 Jul 2014 13:09:05 +0000 (18:39 +0530)
committerMark Brown <broonie@linaro.org>
Thu, 31 Jul 2014 19:18:09 +0000 (20:18 +0100)
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>
Signed-off-by: Mark Brown <broonie@linaro.org>
sound/soc/intel/sst-mfld-platform-pcm.c

index 47df05ed3ac3ccd60bcec06efa2569b2c470ca78..706212a6a68c4c9d873da9d68cf057396ee38bfc 100644 (file)
@@ -570,7 +570,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) {
@@ -578,6 +578,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;