summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesper Juhl <jj@chaosbits.net>2010-12-21 00:03:17 +0100
committerTakashi Iwai <tiwai@suse.de>2010-12-21 08:03:09 +0100
commit87a1c8aaa0bced8acf4cd64672362492460c31ae (patch)
treecbdd1a00380450b7e3f5cdaf027f21792a2498ee
parent022c92befa539174125b0a1b5e52dd57affefe9f (diff)
downloadop-kernel-dev-87a1c8aaa0bced8acf4cd64672362492460c31ae.zip
op-kernel-dev-87a1c8aaa0bced8acf4cd64672362492460c31ae.tar.gz
ALSA: pcm: remember to always call va_end() on stuff that we va_start()
The Coverity checker spotted that we do not always remember to call va_end() on 'args' in failure paths in snd_pcm_hw_rule_add(). Here's a patch to fix that up (compile tested only) - it also removes some annoying trailing whitespace that caught my eye while I was in the area.. Signed-off-by: Jesper Juhl <jj@chaosbits.net> Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r--sound/core/pcm_lib.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
index b75db8e..11446a1 100644
--- a/sound/core/pcm_lib.c
+++ b/sound/core/pcm_lib.c
@@ -1070,8 +1070,10 @@ int snd_pcm_hw_rule_add(struct snd_pcm_runtime *runtime, unsigned int cond,
struct snd_pcm_hw_rule *new;
unsigned int new_rules = constrs->rules_all + 16;
new = kcalloc(new_rules, sizeof(*c), GFP_KERNEL);
- if (!new)
+ if (!new) {
+ va_end(args);
return -ENOMEM;
+ }
if (constrs->rules) {
memcpy(new, constrs->rules,
constrs->rules_num * sizeof(*c));
@@ -1087,8 +1089,10 @@ int snd_pcm_hw_rule_add(struct snd_pcm_runtime *runtime, unsigned int cond,
c->private = private;
k = 0;
while (1) {
- if (snd_BUG_ON(k >= ARRAY_SIZE(c->deps)))
+ if (snd_BUG_ON(k >= ARRAY_SIZE(c->deps))) {
+ va_end(args);
return -EINVAL;
+ }
c->deps[k++] = dep;
if (dep < 0)
break;
@@ -1097,7 +1101,7 @@ int snd_pcm_hw_rule_add(struct snd_pcm_runtime *runtime, unsigned int cond,
constrs->rules_num++;
va_end(args);
return 0;
-}
+}
EXPORT_SYMBOL(snd_pcm_hw_rule_add);
OpenPOWER on IntegriCloud