ASoC: mop500_ab8500: Add a NULL pointer check in mop500_ab8500_machine_init()
authorRajan Vaja <rajan.vaja@gmail.com>
Wed, 20 May 2015 04:50:54 +0000 (10:20 +0530)
committerMark Brown <broonie@kernel.org>
Thu, 21 May 2015 11:05:48 +0000 (12:05 +0100)
Avoid possible crash (NULL pointer dereference) by making
sure that dem_kzalloc() is successful.

Signed-off-by: Rajan Vaja <rajan.vaja@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/ux500/mop500_ab8500.c

index b81a7a4c938b80e7f1eb43c2e3cfc56b4aa4488a..85d810d7667c1992d53a032c203ecf4631ac88f7 100644 (file)
@@ -372,6 +372,10 @@ int mop500_ab8500_machine_init(struct snd_soc_pcm_runtime *rtd)
        /* Create driver private-data struct */
        drvdata = devm_kzalloc(dev, sizeof(struct mop500_ab8500_drvdata),
                        GFP_KERNEL);
+
+       if (!drvdata)
+               return -ENOMEM;
+
        snd_soc_card_set_drvdata(rtd->card, drvdata);
 
        /* Setup clocks */