提交 87a1c8aa 编写于 作者: J Jesper Juhl 提交者: Takashi Iwai

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: NJesper Juhl <jj@chaosbits.net>
Signed-off-by: NTakashi Iwai <tiwai@suse.de>
上级 022c92be
...@@ -1070,8 +1070,10 @@ int snd_pcm_hw_rule_add(struct snd_pcm_runtime *runtime, unsigned int cond, ...@@ -1070,8 +1070,10 @@ int snd_pcm_hw_rule_add(struct snd_pcm_runtime *runtime, unsigned int cond,
struct snd_pcm_hw_rule *new; struct snd_pcm_hw_rule *new;
unsigned int new_rules = constrs->rules_all + 16; unsigned int new_rules = constrs->rules_all + 16;
new = kcalloc(new_rules, sizeof(*c), GFP_KERNEL); new = kcalloc(new_rules, sizeof(*c), GFP_KERNEL);
if (!new) if (!new) {
va_end(args);
return -ENOMEM; return -ENOMEM;
}
if (constrs->rules) { if (constrs->rules) {
memcpy(new, constrs->rules, memcpy(new, constrs->rules,
constrs->rules_num * sizeof(*c)); constrs->rules_num * sizeof(*c));
...@@ -1087,8 +1089,10 @@ int snd_pcm_hw_rule_add(struct snd_pcm_runtime *runtime, unsigned int cond, ...@@ -1087,8 +1089,10 @@ int snd_pcm_hw_rule_add(struct snd_pcm_runtime *runtime, unsigned int cond,
c->private = private; c->private = private;
k = 0; k = 0;
while (1) { 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; return -EINVAL;
}
c->deps[k++] = dep; c->deps[k++] = dep;
if (dep < 0) if (dep < 0)
break; break;
...@@ -1097,7 +1101,7 @@ int snd_pcm_hw_rule_add(struct snd_pcm_runtime *runtime, unsigned int cond, ...@@ -1097,7 +1101,7 @@ int snd_pcm_hw_rule_add(struct snd_pcm_runtime *runtime, unsigned int cond,
constrs->rules_num++; constrs->rules_num++;
va_end(args); va_end(args);
return 0; return 0;
} }
EXPORT_SYMBOL(snd_pcm_hw_rule_add); EXPORT_SYMBOL(snd_pcm_hw_rule_add);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册