diff mbox

ASoC: mop500_ab8500: Add a NULL pointer check in mop500_ab8500_machine_init()

Message ID 1432097454-3643-1-git-send-email-rajan.vaja@gmail.com (mailing list archive)
State Accepted
Commit 72f0095e7993dd9af8d5531740bf549359314bf0
Headers show

Commit Message

Rajan Vaja May 20, 2015, 4:50 a.m. UTC
Avoid possible crash (NULL pointer dereference) by making
sure that dem_kzalloc() is successful.

Signed-off-by: Rajan Vaja <rajan.vaja@gmail.com>
---
 sound/soc/ux500/mop500_ab8500.c |    4 ++++
 1 file changed, 4 insertions(+)

Comments

Mark Brown May 21, 2015, 11:05 a.m. UTC | #1
On Wed, May 20, 2015 at 10:20:54AM +0530, Rajan Vaja wrote:
> Avoid possible crash (NULL pointer dereference) by making
> sure that dem_kzalloc() is successful.

Applied, thanks.
diff mbox

Patch

diff --git a/sound/soc/ux500/mop500_ab8500.c b/sound/soc/ux500/mop500_ab8500.c
index b81a7a4c..85d810d 100644
--- a/sound/soc/ux500/mop500_ab8500.c
+++ b/sound/soc/ux500/mop500_ab8500.c
@@ -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 */