All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch] ALSA: soc-cache: dereferencing before checking
@ 2011-02-07 19:01 ` Dan Carpenter
  0 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2011-02-07 19:01 UTC (permalink / raw)
  To: Liam Girdwood; +Cc: Takashi Iwai, alsa-devel, Mark Brown, kernel-janitors

The patch c358e640a66 "ASoC: soc-cache: Add trace event for
snd_soc_cache_sync()" introduced a dereference of "codec->cache_ops"
before we had checked it for NULL.

I pulled the check forward, and then pulled everything in an indent
level.

Signed-off-by: Dan Carpenter <error27@gmail.com>

diff --git a/sound/soc/soc-cache.c b/sound/soc/soc-cache.c
index db66dc4..5d76da4 100644
--- a/sound/soc/soc-cache.c
+++ b/sound/soc/soc-cache.c
@@ -1609,24 +1609,23 @@ int snd_soc_cache_sync(struct snd_soc_codec *codec)
 		return 0;
 	}
 
+	if (!codec->cache_ops || !codec->cache_ops->sync)
+		return -EINVAL;
+
 	if (codec->cache_ops->name)
 		name = codec->cache_ops->name;
 	else
 		name = "unknown";
 
-	if (codec->cache_ops && codec->cache_ops->sync) {
-		if (codec->cache_ops->name)
-			dev_dbg(codec->dev, "Syncing %s cache for %s codec\n",
-				codec->cache_ops->name, codec->name);
-		trace_snd_soc_cache_sync(codec, name, "start");
-		ret = codec->cache_ops->sync(codec);
-		if (!ret)
-			codec->cache_sync = 0;
-		trace_snd_soc_cache_sync(codec, name, "end");
-		return ret;
-	}
-
-	return -EINVAL;
+	if (codec->cache_ops->name)
+		dev_dbg(codec->dev, "Syncing %s cache for %s codec\n",
+			codec->cache_ops->name, codec->name);
+	trace_snd_soc_cache_sync(codec, name, "start");
+	ret = codec->cache_ops->sync(codec);
+	if (!ret)
+		codec->cache_sync = 0;
+	trace_snd_soc_cache_sync(codec, name, "end");
+	return ret;
 }
 EXPORT_SYMBOL_GPL(snd_soc_cache_sync);

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [patch] ALSA: soc-cache: dereferencing before checking
@ 2011-02-07 19:01 ` Dan Carpenter
  0 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2011-02-07 19:01 UTC (permalink / raw)
  To: Liam Girdwood; +Cc: Takashi Iwai, alsa-devel, Mark Brown, kernel-janitors

The patch c358e640a66 "ASoC: soc-cache: Add trace event for
snd_soc_cache_sync()" introduced a dereference of "codec->cache_ops"
before we had checked it for NULL.

I pulled the check forward, and then pulled everything in an indent
level.

Signed-off-by: Dan Carpenter <error27@gmail.com>

diff --git a/sound/soc/soc-cache.c b/sound/soc/soc-cache.c
index db66dc4..5d76da4 100644
--- a/sound/soc/soc-cache.c
+++ b/sound/soc/soc-cache.c
@@ -1609,24 +1609,23 @@ int snd_soc_cache_sync(struct snd_soc_codec *codec)
 		return 0;
 	}
 
+	if (!codec->cache_ops || !codec->cache_ops->sync)
+		return -EINVAL;
+
 	if (codec->cache_ops->name)
 		name = codec->cache_ops->name;
 	else
 		name = "unknown";
 
-	if (codec->cache_ops && codec->cache_ops->sync) {
-		if (codec->cache_ops->name)
-			dev_dbg(codec->dev, "Syncing %s cache for %s codec\n",
-				codec->cache_ops->name, codec->name);
-		trace_snd_soc_cache_sync(codec, name, "start");
-		ret = codec->cache_ops->sync(codec);
-		if (!ret)
-			codec->cache_sync = 0;
-		trace_snd_soc_cache_sync(codec, name, "end");
-		return ret;
-	}
-
-	return -EINVAL;
+	if (codec->cache_ops->name)
+		dev_dbg(codec->dev, "Syncing %s cache for %s codec\n",
+			codec->cache_ops->name, codec->name);
+	trace_snd_soc_cache_sync(codec, name, "start");
+	ret = codec->cache_ops->sync(codec);
+	if (!ret)
+		codec->cache_sync = 0;
+	trace_snd_soc_cache_sync(codec, name, "end");
+	return ret;
 }
 EXPORT_SYMBOL_GPL(snd_soc_cache_sync);
 

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [patch] ALSA: soc-cache: dereferencing before checking
  2011-02-07 19:01 ` Dan Carpenter
@ 2011-02-07 19:11   ` Liam Girdwood
  -1 siblings, 0 replies; 8+ messages in thread
From: Liam Girdwood @ 2011-02-07 19:11 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Takashi Iwai, alsa-devel, Mark Brown, kernel-janitors

On Mon, 2011-02-07 at 22:01 +0300, Dan Carpenter wrote:
> The patch c358e640a66 "ASoC: soc-cache: Add trace event for
> snd_soc_cache_sync()" introduced a dereference of "codec->cache_ops"
> before we had checked it for NULL.
> 
> I pulled the check forward, and then pulled everything in an indent
> level.
> 
> Signed-off-by: Dan Carpenter <error27@gmail.com>

Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
-- 
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [alsa-devel] [patch] ALSA: soc-cache: dereferencing before
@ 2011-02-07 19:11   ` Liam Girdwood
  0 siblings, 0 replies; 8+ messages in thread
From: Liam Girdwood @ 2011-02-07 19:11 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Takashi Iwai, alsa-devel, Mark Brown, kernel-janitors

On Mon, 2011-02-07 at 22:01 +0300, Dan Carpenter wrote:
> The patch c358e640a66 "ASoC: soc-cache: Add trace event for
> snd_soc_cache_sync()" introduced a dereference of "codec->cache_ops"
> before we had checked it for NULL.
> 
> I pulled the check forward, and then pulled everything in an indent
> level.
> 
> Signed-off-by: Dan Carpenter <error27@gmail.com>

Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
-- 
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [patch] ALSA: soc-cache: dereferencing before checking
  2011-02-07 19:01 ` Dan Carpenter
@ 2011-02-08 10:45   ` Dimitris Papastamos
  -1 siblings, 0 replies; 8+ messages in thread
From: Dimitris Papastamos @ 2011-02-08 10:45 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Takashi Iwai, alsa-devel, Mark Brown, kernel-janitors,
	Liam Girdwood

On Mon, 2011-02-07 at 22:01 +0300, Dan Carpenter wrote:
> The patch c358e640a66 "ASoC: soc-cache: Add trace event for
> snd_soc_cache_sync()" introduced a dereference of "codec->cache_ops"
> before we had checked it for NULL.
> 
> I pulled the check forward, and then pulled everything in an indent
> level.
> 
> Signed-off-by: Dan Carpenter <error27@gmail.com>

Dah, thanks for catching this.

Dimitris

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [alsa-devel] [patch] ALSA: soc-cache: dereferencing before
@ 2011-02-08 10:45   ` Dimitris Papastamos
  0 siblings, 0 replies; 8+ messages in thread
From: Dimitris Papastamos @ 2011-02-08 10:45 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Takashi Iwai, alsa-devel, Mark Brown, kernel-janitors,
	Liam Girdwood

On Mon, 2011-02-07 at 22:01 +0300, Dan Carpenter wrote:
> The patch c358e640a66 "ASoC: soc-cache: Add trace event for
> snd_soc_cache_sync()" introduced a dereference of "codec->cache_ops"
> before we had checked it for NULL.
> 
> I pulled the check forward, and then pulled everything in an indent
> level.
> 
> Signed-off-by: Dan Carpenter <error27@gmail.com>

Dah, thanks for catching this.

Dimitris


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [patch] ALSA: soc-cache: dereferencing before checking
  2011-02-07 19:01 ` Dan Carpenter
@ 2011-02-08 11:32   ` Mark Brown
  -1 siblings, 0 replies; 8+ messages in thread
From: Mark Brown @ 2011-02-08 11:32 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Takashi Iwai, alsa-devel, kernel-janitors, Liam Girdwood

On Mon, Feb 07, 2011 at 10:01:41PM +0300, Dan Carpenter wrote:
> The patch c358e640a66 "ASoC: soc-cache: Add trace event for
> snd_soc_cache_sync()" introduced a dereference of "codec->cache_ops"
> before we had checked it for NULL.

Applied, thanks.  Please try to use subject lines for your patches which
are consistent with the subsystem you're submitting to.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [patch] ALSA: soc-cache: dereferencing before checking
@ 2011-02-08 11:32   ` Mark Brown
  0 siblings, 0 replies; 8+ messages in thread
From: Mark Brown @ 2011-02-08 11:32 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Takashi Iwai, alsa-devel, kernel-janitors, Liam Girdwood

On Mon, Feb 07, 2011 at 10:01:41PM +0300, Dan Carpenter wrote:
> The patch c358e640a66 "ASoC: soc-cache: Add trace event for
> snd_soc_cache_sync()" introduced a dereference of "codec->cache_ops"
> before we had checked it for NULL.

Applied, thanks.  Please try to use subject lines for your patches which
are consistent with the subsystem you're submitting to.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2011-02-08 11:32 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-07 19:01 [patch] ALSA: soc-cache: dereferencing before checking Dan Carpenter
2011-02-07 19:01 ` Dan Carpenter
2011-02-07 19:11 ` Liam Girdwood
2011-02-07 19:11   ` [alsa-devel] [patch] ALSA: soc-cache: dereferencing before Liam Girdwood
2011-02-08 10:45 ` [patch] ALSA: soc-cache: dereferencing before checking Dimitris Papastamos
2011-02-08 10:45   ` [alsa-devel] [patch] ALSA: soc-cache: dereferencing before Dimitris Papastamos
2011-02-08 11:32 ` [patch] ALSA: soc-cache: dereferencing before checking Mark Brown
2011-02-08 11:32   ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.