diff options
author | Takashi Iwai <tiwai@suse.de> | 2019-05-31 11:44:44 +0200 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2019-05-31 11:44:44 +0200 |
commit | 65be9580885e4c14af1448b5bac95517c52a7ad3 (patch) | |
tree | ac4462b112956c79e281af721da45555869f2157 /sound/core/control.c | |
parent | c86ccfba17289a7795e6bf8528c2824508fe86f8 (diff) | |
download | linux-stable-65be9580885e4c14af1448b5bac95517c52a7ad3.tar.gz linux-stable-65be9580885e4c14af1448b5bac95517c52a7ad3.tar.bz2 linux-stable-65be9580885e4c14af1448b5bac95517c52a7ad3.zip |
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: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/core/control.c')
-rw-r--r-- | sound/core/control.c | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/sound/core/control.c b/sound/core/control.c index a5cc9a874062..04eb1a15ffb4 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -211,16 +211,12 @@ EXPORT_SYMBOL(snd_ctl_notify); static int snd_ctl_new(struct snd_kcontrol **kctl, unsigned int count, unsigned int access, struct snd_ctl_file *file) { - unsigned int size; unsigned int idx; if (count == 0 || count > MAX_CONTROL_COUNT) return -EINVAL; - size = sizeof(struct snd_kcontrol); - size += sizeof(struct snd_kcontrol_volatile) * count; - - *kctl = kzalloc(size, GFP_KERNEL); + *kctl = kzalloc(struct_size(*kctl, vd, count), GFP_KERNEL); if (!*kctl) return -ENOMEM; |