Skip to content

Commit 2c84067

Browse files
evdenisKalle Valo
authored andcommitted
wil6210: check len before memcpy() calls
memcpy() in wmi_set_ie() and wmi_update_ft_ies() is called with src == NULL and len == 0. This is an undefined behavior. Fix it by checking "ie_len > 0" before the memcpy() calls. As suggested by GCC documentation: "The pointers passed to memmove (and similar functions in <string.h>) must be non-null even when nbytes==0, so GCC can use that information to remove the check after the memmove call." [1] [1] https://gcc.gnu.org/gcc-4.9/porting_to.html Cc: Maya Erez <merez@codeaurora.org> Cc: Kalle Valo <kvalo@codeaurora.org> Cc: "David S. Miller" <davem@davemloft.net> Cc: stable@vger.kernel.org Signed-off-by: Denis Efremov <efremov@linux.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
1 parent 315cee4 commit 2c84067

File tree

1 file changed

+4
-2
lines changed
  • drivers/net/wireless/ath/wil6210

1 file changed

+4
-2
lines changed

drivers/net/wireless/ath/wil6210/wmi.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2505,7 +2505,8 @@ int wmi_set_ie(struct wil6210_vif *vif, u8 type, u16 ie_len, const void *ie)
25052505
cmd->mgmt_frm_type = type;
25062506
/* BUG: FW API define ieLen as u8. Will fix FW */
25072507
cmd->ie_len = cpu_to_le16(ie_len);
2508-
memcpy(cmd->ie_info, ie, ie_len);
2508+
if (ie_len)
2509+
memcpy(cmd->ie_info, ie, ie_len);
25092510
rc = wmi_send(wil, WMI_SET_APPIE_CMDID, vif->mid, cmd, len);
25102511
kfree(cmd);
25112512
out:
@@ -2541,7 +2542,8 @@ int wmi_update_ft_ies(struct wil6210_vif *vif, u16 ie_len, const void *ie)
25412542
}
25422543

25432544
cmd->ie_len = cpu_to_le16(ie_len);
2544-
memcpy(cmd->ie_info, ie, ie_len);
2545+
if (ie_len)
2546+
memcpy(cmd->ie_info, ie, ie_len);
25452547
rc = wmi_send(wil, WMI_UPDATE_FT_IES_CMDID, vif->mid, cmd, len);
25462548
kfree(cmd);
25472549

0 commit comments

Comments
 (0)