]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
ath6kl: debug: Use struct_size() helper
authorGustavo A. R. Silva <gustavo@embeddedor.com>
Wed, 3 Apr 2019 15:48:35 +0000 (10:48 -0500)
committerKalle Valo <kvalo@codeaurora.org>
Mon, 29 Apr 2019 14:43:35 +0000 (17:43 +0300)
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 <gustavo@embeddedor.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/ath/ath6kl/debug.c

index 4e94b22eaada1da4fad5f6193a4c6a8c942b50c5..54337d60f288b169a27509dc85d21d498d0f53a8 100644 (file)
@@ -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 ||