[alsa-devel] [PATCH 6/6] ASoC: dapm: Fix potential NULL pointer dereference

Sachin Kamat sachin.kamat at linaro.org
Wed Nov 21 10:06:59 CET 2012


'w' should not be dereferenced when it is NULL.

Cc: Liam Girdwood <lrg at ti.com>
Cc: Mark Brown <broonie at opensource.wolfsonmicro.com>
Signed-off-by: Sachin Kamat <sachin.kamat at linaro.org>
---
Build tested and based on linux-next 20121115.
---
 sound/soc/soc-dapm.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 6e35bca..5bde5d4 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -3326,9 +3326,9 @@ int snd_soc_dapm_new_dai_widgets(struct snd_soc_dapm_context *dapm,
 		if (!w) {
 			dev_err(dapm->dev, "Failed to create %s widget\n",
 				dai->driver->playback.stream_name);
+		} else {
+			w->priv = dai;
 		}
-
-		w->priv = dai;
 		dai->playback_widget = w;
 	}
 
@@ -3344,9 +3344,9 @@ int snd_soc_dapm_new_dai_widgets(struct snd_soc_dapm_context *dapm,
 		if (!w) {
 			dev_err(dapm->dev, "Failed to create %s widget\n",
 				dai->driver->capture.stream_name);
+		} else {
+			w->priv = dai;
 		}
-
-		w->priv = dai;
 		dai->capture_widget = w;
 	}
 
-- 
1.7.4.1



More information about the Alsa-devel mailing list