usb: xhci-mtk: Use struct_size() helper in create_sch_ep()
authorGustavo A. R. Silva <gustavoars@kernel.org>
Thu, 20 Jan 2022 01:55:46 +0000 (19:55 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 26 Jan 2022 13:03:26 +0000 (14:03 +0100)
commite62667f82aa6b14faa6abfe395b7351f63b8db8f
treeabfbe1e025d8b050c952ce939bbd94dfbedeef70
parent5d0c4393b207660fb9d6b08caed03ac85435fcd9
usb: xhci-mtk: Use struct_size() helper in create_sch_ep()

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:
drivers/usb/host/xhci-mtk-sch.c:265:20: warning: using sizeof on a flexible structure

Link: https://github.com/KSPP/linux/issues/160
Link: https://github.com/KSPP/linux/issues/174
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Acked-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Link: https://lore.kernel.org/r/20220120015546.GA75917@embeddedor
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/host/xhci-mtk-sch.c