ALSA: usb-audio: scarlett2: Use struct_size() helper in scarlett2_usb()
authorGustavo A. R. Silva <gustavoars@kernel.org>
Thu, 20 Jan 2022 21:16:00 +0000 (15:16 -0600)
committerTakashi Iwai <tiwai@suse.de>
Tue, 25 Jan 2022 14:11:21 +0000 (15:11 +0100)
commit2b101256fd552bf2e29980d51394ebd88737159c
treee268bc52ad124c5997bc5c6483024ad789e84d6c
parente783362eb54cd99b2cac8b3a9aeac942e6f6ac07
ALSA: usb-audio: scarlett2: Use struct_size() helper in scarlett2_usb()

Make use of the struct_size() helper instead of an open-coded version,
in order to avoid any potential type mistakes or integer overflows that,
in the worst scenario, could lead to heap overflows.

Also, address the following sparse warnings:
sound/usb/mixer_scarlett_gen2.c:1064:28: warning: using sizeof on a flexible structure
sound/usb/mixer_scarlett_gen2.c:1065:29: warning: using sizeof on a flexible structure

Link: https://github.com/KSPP/linux/issues/174
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20220120211600.GA28841@embeddedor
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/usb/mixer_scarlett_gen2.c