From: Gustavo A. R. Silva Date: Wed, 3 Apr 2019 15:48:35 +0000 (-0500) Subject: ath6kl: debug: Use struct_size() helper X-Git-Tag: v5.3-rc1~140^2~141^2~61^2~37 X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=commitdiff_plain;h=df75786b9233be9e4ce9608df2c1cdc8b20e13df;p=linux.git ath6kl: debug: Use struct_size() helper Make use of the struct_size() helper instead of an open-coded version in order to avoid any potential type mistakes, in particular in the context in which this code is being used. So, change the following form: sizeof(*tbl) + num_entries * sizeof(struct wmi_bss_roam_info) to : struct_size(tbl, info, num_entries) This code was detected with the help of Coccinelle. Signed-off-by: Gustavo A. R. Silva Signed-off-by: Kalle Valo --- diff --git a/drivers/net/wireless/ath/ath6kl/debug.c b/drivers/net/wireless/ath/ath6kl/debug.c index 4e94b22eaada..54337d60f288 100644 --- a/drivers/net/wireless/ath/ath6kl/debug.c +++ b/drivers/net/wireless/ath/ath6kl/debug.c @@ -1132,8 +1132,7 @@ int ath6kl_debug_roam_tbl_event(struct ath6kl *ar, const void *buf, tbl = (const struct wmi_target_roam_tbl *) buf; num_entries = le16_to_cpu(tbl->num_entries); - if (sizeof(*tbl) + num_entries * sizeof(struct wmi_bss_roam_info) > - len) + if (struct_size(tbl, info, num_entries) > len) return -EINVAL; if (ar->debug.roam_tbl == NULL ||