Skip to content

Commit

Permalink
ar5523: check NULL before memcpy() in ar5523_cmd()
Browse files Browse the repository at this point in the history
memcpy() call with "idata == NULL && ilen == 0" results in undefined
behavior in ar5523_cmd(). For example, NULL is passed in callchain
"ar5523_stat_work() -> ar5523_cmd_write() -> ar5523_cmd()". This patch
adds ilen check before memcpy() call in ar5523_cmd() to prevent an
undefined behavior.

Cc: Pontus Fuchs <[email protected]>
Cc: Kalle Valo <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: David Laight <[email protected]>
Cc: [email protected]
Signed-off-by: Denis Efremov <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
  • Loading branch information
evdenis authored and Kalle Valo committed Oct 2, 2019
1 parent 1382993 commit 315cee4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/net/wireless/ath/ar5523/ar5523.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ static int ar5523_cmd(struct ar5523 *ar, u32 code, const void *idata,

if (flags & AR5523_CMD_FLAG_MAGIC)
hdr->magic = cpu_to_be32(1 << 24);
memcpy(hdr + 1, idata, ilen);
if (ilen)
memcpy(hdr + 1, idata, ilen);

cmd->odata = odata;
cmd->olen = olen;
Expand Down

0 comments on commit 315cee4

Please sign in to comment.