Skip to content

Commit 09b9ddf

Browse files
committed
ALSA: pcm: Use krealloc() for resizing the rules array
Just a minor simplification. Change from kcalloc() shouldn't matter as each array element is fully initialized. Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 5730f9f commit 09b9ddf

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

sound/core/pcm_lib.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,16 +1129,12 @@ int snd_pcm_hw_rule_add(struct snd_pcm_runtime *runtime, unsigned int cond,
11291129
if (constrs->rules_num >= constrs->rules_all) {
11301130
struct snd_pcm_hw_rule *new;
11311131
unsigned int new_rules = constrs->rules_all + 16;
1132-
new = kcalloc(new_rules, sizeof(*c), GFP_KERNEL);
1132+
new = krealloc(constrs->rules, new_rules * sizeof(*c),
1133+
GFP_KERNEL);
11331134
if (!new) {
11341135
va_end(args);
11351136
return -ENOMEM;
11361137
}
1137-
if (constrs->rules) {
1138-
memcpy(new, constrs->rules,
1139-
constrs->rules_num * sizeof(*c));
1140-
kfree(constrs->rules);
1141-
}
11421138
constrs->rules = new;
11431139
constrs->rules_all = new_rules;
11441140
}

0 commit comments

Comments
 (0)