diff mbox

[6/6] ASoC: dapm: Fix potential NULL pointer dereference

Message ID 1353488819-13902-6-git-send-email-sachin.kamat@linaro.org
State Rejected
Headers show

Commit Message

Sachin Kamat Nov. 21, 2012, 9:06 a.m. UTC
'w' should not be dereferenced when it is NULL.

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

Comments

Sachin Kamat Nov. 28, 2012, 4:43 a.m. UTC | #1
Not sure if this patch got lost.
Just a gentle reminder.

On 21 November 2012 14:36, Sachin Kamat <sachin.kamat@linaro.org> wrote:
> 'w' should not be dereferenced when it is NULL.
>
> Cc: Liam Girdwood <lrg@ti.com>
> Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>
> Signed-off-by: Sachin Kamat <sachin.kamat@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
>
Mark Brown Nov. 28, 2012, 5:28 p.m. UTC | #2
On Wed, Nov 28, 2012 at 10:13:58AM +0530, Sachin Kamat wrote:
> Not sure if this patch got lost.
> Just a gentle reminder.

Don't send contentless pings or top post.  If the patch has been lost
it's not helpful to have a copy covered in quotation marks.
Mark Brown Dec. 2, 2012, 4:14 a.m. UTC | #3
On Wed, Nov 21, 2012 at 02:36:59PM +0530, Sachin Kamat wrote:

>  		if (!w) {
>  			dev_err(dapm->dev, "Failed to create %s widget\n",
>  				dai->driver->playback.stream_name);
> +		} else {
> +			w->priv = dai;
>  		}

This isn't a particularly sensible fix, we should be erroring out or
something rather than limping along with the rest of the function.
diff mbox

Patch

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;
 	}