diff options
author | Dan Carpenter <error27@gmail.com> | 2011-02-07 22:01:41 +0300 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2011-02-08 11:27:45 +0000 |
commit | 46fdaa3bec1bcaa36759b1f5e5e27245ae465b8f (patch) | |
tree | 2ce1696415cd65f6722a8bd4116ca8c1971f702d /sound/soc/soc-cache.c | |
parent | a98a0bc6c92eacd181417a9c0ccd2e8028066622 (diff) | |
download | linux-46fdaa3bec1bcaa36759b1f5e5e27245ae465b8f.tar.gz linux-46fdaa3bec1bcaa36759b1f5e5e27245ae465b8f.tar.bz2 linux-46fdaa3bec1bcaa36759b1f5e5e27245ae465b8f.zip |
ASoC: soc-cache: dereferencing before checking
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>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/soc-cache.c')
-rw-r--r-- | sound/soc/soc-cache.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/sound/soc/soc-cache.c b/sound/soc/soc-cache.c index db66dc44add2..5d76da43b14c 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); |