Commit 65be9580 authored by Takashi Iwai's avatar Takashi Iwai

ALSA: control: Use struct_size()

For code simplification and safety, use struct_size() macro for
calculating the snd_kcontrol object size with the variable array.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent c86ccfba
...@@ -211,16 +211,12 @@ EXPORT_SYMBOL(snd_ctl_notify); ...@@ -211,16 +211,12 @@ EXPORT_SYMBOL(snd_ctl_notify);
static int snd_ctl_new(struct snd_kcontrol **kctl, unsigned int count, static int snd_ctl_new(struct snd_kcontrol **kctl, unsigned int count,
unsigned int access, struct snd_ctl_file *file) unsigned int access, struct snd_ctl_file *file)
{ {
unsigned int size;
unsigned int idx; unsigned int idx;
if (count == 0 || count > MAX_CONTROL_COUNT) if (count == 0 || count > MAX_CONTROL_COUNT)
return -EINVAL; return -EINVAL;
size = sizeof(struct snd_kcontrol); *kctl = kzalloc(struct_size(*kctl, vd, count), GFP_KERNEL);
size += sizeof(struct snd_kcontrol_volatile) * count;
*kctl = kzalloc(size, GFP_KERNEL);
if (!*kctl) if (!*kctl)
return -ENOMEM; return -ENOMEM;
......
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