diff options
| author | msaitoh <msaitoh@NetBSD.org> | 2019-07-25 14:31:35 +0000 |
|---|---|---|
| committer | msaitoh <msaitoh@NetBSD.org> | 2019-07-25 14:31:35 +0000 |
| commit | ef8dd2007d11fc152d80f802c3954c5038d73fc9 (patch) | |
| tree | 64ae110ed8a4598a90f93b6da028f796720f1b22 /sys/dev | |
| parent | 00f87f9f4e81dde57d948368af621ff0c9a242e1 (diff) | |
Avoid undefined behavior. Found by KUBSan.
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/ic/rtwnreg.h | 5 | ||||
| -rw-r--r-- | sys/dev/usb/if_urtwn.c | 8 |
2 files changed, 7 insertions, 6 deletions
diff --git a/sys/dev/ic/rtwnreg.h b/sys/dev/ic/rtwnreg.h index eae63bb1383..dad243e83ce 100644 --- a/sys/dev/ic/rtwnreg.h +++ b/sys/dev/ic/rtwnreg.h @@ -1,4 +1,4 @@ -/* $NetBSD: rtwnreg.h,v 1.1 2018/06/29 04:02:10 thorpej Exp $ */ +/* $NetBSD: rtwnreg.h,v 1.2 2019/07/25 14:31:35 msaitoh Exp $ */ /* $OpenBSD: r92creg.h,v 1.16 2017/09/22 13:41:56 kevlo Exp $ */ /*- @@ -1031,7 +1031,8 @@ /* Macros to access unaligned little-endian memory. */ #define LE_READ_2(x) ((x)[0] | ((x)[1] << 8)) -#define LE_READ_4(x) ((x)[0] | ((x)[1] << 8) | ((x)[2] << 16) | ((x)[3] << 24)) +#define LE_READ_4(x) ((x)[0] | ((x)[1] << 8) | ((x)[2] << 16) | \ + ((uint32_t)((x)[3]) << 24)) /* * Macros to access subfields in registers. diff --git a/sys/dev/usb/if_urtwn.c b/sys/dev/usb/if_urtwn.c index d7e40032671..5b81b692c96 100644 --- a/sys/dev/usb/if_urtwn.c +++ b/sys/dev/usb/if_urtwn.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_urtwn.c,v 1.70 2019/06/15 04:00:17 msaitoh Exp $ */ +/* $NetBSD: if_urtwn.c,v 1.71 2019/07/25 14:31:35 msaitoh Exp $ */ /* $OpenBSD: if_urtwn.c,v 1.42 2015/02/10 23:25:46 mpi Exp $ */ /*- @@ -25,7 +25,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.70 2019/06/15 04:00:17 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.71 2019/07/25 14:31:35 msaitoh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -1092,13 +1092,13 @@ urtwn_fw_cmd(struct urtwn_softc *sc, uint8_t id, const void *buf, int len) &cp[1], 2); urtwn_write_4(sc, R92C_HMEBOX(fwcur), cp[0] + (cp[3] << 8) + (cp[4] << 16) + - (cp[5] << 24)); + ((uint32_t)cp[5] << 24)); } else { urtwn_write_region(sc, R92E_HMEBOX_EXT(fwcur), &cp[4], 2); urtwn_write_4(sc, R92C_HMEBOX(fwcur), cp[0] + (cp[1] << 8) + (cp[2] << 16) + - (cp[3] << 24)); + ((uint32_t)cp[3] << 24)); } } else { urtwn_write_region(sc, R92C_HMEBOX(fwcur), cp, len); |
