Message ID | 20190403154835.GA20955@embeddedor (mailing list archive) |
---|---|
State | Accepted |
Commit | df75786b9233be9e4ce9608df2c1cdc8b20e13df |
Delegated to: | Kalle Valo |
Headers | show |
Series | [next] ath6kl: debug: Use struct_size() helper | expand |
"Gustavo A. R. Silva" <gustavo@embeddedor.com> wrote: > 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> Patch applied to ath-next branch of ath.git, thanks. df75786b9233 ath6kl: debug: Use struct_size() helper
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 ||
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> --- drivers/net/wireless/ath/ath6kl/debug.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)