Commit 3b2328a8 authored by Jaroslav Kysela's avatar Jaroslav Kysela

ALSA CVS update

PCM Midlevel
fix memory leak
Signed-off-by: default avatarClemens Ladisch <clemens@ladisch.de>
parent 9c712fbc
......@@ -887,22 +887,18 @@ int snd_pcm_hw_rule_add(snd_pcm_runtime_t *runtime, unsigned int cond,
va_list args;
va_start(args, dep);
if (constrs->rules_num >= constrs->rules_all) {
snd_pcm_hw_rule_t *old = constrs->rules;
if (constrs->rules_all == 0)
constrs->rules_all = 32;
else {
old = constrs->rules;
constrs->rules_all += 10;
}
constrs->rules = kcalloc(constrs->rules_all, sizeof(*c),
GFP_KERNEL);
if (!constrs->rules)
snd_pcm_hw_rule_t *new;
unsigned int new_rules = constrs->rules_all + 16;
new = kcalloc(new_rules, sizeof(*c), GFP_KERNEL);
if (!new)
return -ENOMEM;
if (old) {
memcpy(constrs->rules, old,
if (constrs->rules) {
memcpy(new, constrs->rules,
constrs->rules_num * sizeof(*c));
kfree(old);
kfree(constrs->rules);
}
constrs->rules = new;
constrs->rules_all = new_rules;
}
c = &constrs->rules[constrs->rules_num];
c->cond = cond;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment