ASoC: Intel: add NULL test
authorJulia Lawall <Julia.Lawall@lip6.fr>
Sun, 20 Dec 2015 11:15:53 +0000 (12:15 +0100)
committerMark Brown <broonie@kernel.org>
Wed, 23 Dec 2015 00:02:17 +0000 (00:02 +0000)
Add NULL test on call to devm_kzalloc.

The semantic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression x;
identifier fld;
@@

* x = devm_kzalloc(...);
  ... when != x == NULL
  x->fld
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/intel/baytrail/sst-baytrail-pcm.c

index 79547bec558bc218c505be5a68321497c9dfd70e..4765ad4745444b68929f4282271a6b5cdfe0a9be 100644 (file)
@@ -377,6 +377,8 @@ static int sst_byt_pcm_probe(struct snd_soc_platform *platform)
 
        priv_data = devm_kzalloc(platform->dev, sizeof(*priv_data),
                                 GFP_KERNEL);
+       if (!priv_data)
+               return -ENOMEM;
        priv_data->byt = plat_data->dsp;
        snd_soc_platform_set_drvdata(platform, priv_data);