From: Takashi Iwai Date: Fri, 31 May 2019 09:46:49 +0000 (+0200) Subject: ALSA: hda: Use struct_size() X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=a2d4560f0be9a48cd342992fbec0688ea05d564b;p=android-x86%2Fkernel.git ALSA: hda: Use struct_size() For code simplification and safety, use struct_size() macro for calculating the hda_conn_list object size with the variable array. Signed-off-by: Takashi Iwai --- diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index b20eb7fc83eb..d0f1dbcfbda4 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -122,7 +122,7 @@ static int add_conn_list(struct hda_codec *codec, hda_nid_t nid, int len, { struct hda_conn_list *p; - p = kmalloc(sizeof(*p) + len * sizeof(hda_nid_t), GFP_KERNEL); + p = kmalloc(struct_size(p, conns, len), GFP_KERNEL); if (!p) return -ENOMEM; p->len = len;