ASoC: omap-hdmi-audio: add NULL test
authorJulia Lawall <Julia.Lawall@lip6.fr>
Sun, 20 Dec 2015 11:15:51 +0000 (12:15 +0100)
committerMark Brown <broonie@kernel.org>
Wed, 23 Dec 2015 00:02:04 +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>
Acked-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/omap/omap-hdmi-audio.c

index 584b2372339ef4e7f985ca0c11a77d300eb84888..f83cc2bc0fc41a3434e0dca238569e613e3bad22 100644 (file)
@@ -368,6 +368,8 @@ static int omap_hdmi_audio_probe(struct platform_device *pdev)
        card->owner = THIS_MODULE;
        card->dai_link =
                devm_kzalloc(dev, sizeof(*(card->dai_link)), GFP_KERNEL);
+       if (!card->dai_link)
+               return -ENOMEM;
        card->dai_link->name = card->name;
        card->dai_link->stream_name = card->name;
        card->dai_link->cpu_dai_name = dev_name(ad->dssdev);