ASoC: davinci-mcasp: check memory allocation failure
authorChristophe Jaillet <christophe.jaillet@wanadoo.fr>
Sun, 27 Aug 2017 06:46:50 +0000 (08:46 +0200)
committerMark Brown <broonie@kernel.org>
Sun, 27 Aug 2017 12:30:29 +0000 (13:30 +0100)
Check memory allocation failures and return -ENOMEM in such cases, as
already done above for another memory allocation.

This avoids NULL pointers dereference.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/davinci/davinci-mcasp.c

index d486908d4e0e5ed0fa74838dc0df6f3e7933701d..f395bbc7c354549d089ecfbb8a633e0d4e2aadac 100644 (file)
@@ -1851,6 +1851,10 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
        mcasp->context.xrsr_regs = devm_kzalloc(&pdev->dev,
                                        sizeof(u32) * mcasp->num_serializer,
                                        GFP_KERNEL);
+       if (!mcasp->context.xrsr_regs) {
+               ret = -ENOMEM;
+               goto err;
+       }
 #endif
        mcasp->serial_dir = pdata->serial_dir;
        mcasp->version = pdata->version;