Module Name: src Committed By: msaitoh Date: Sat Jan 25 07:57:48 UTC 2020
Modified Files: src/sys/dev/pci: if_aq.c Log Message: Found by kUBSan: - Use unsigned to avoid undefined behavior in aq_hw_init(). - Cast to unsigned to avoid undefined behavior in aq_set_mac_addr(). To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/dev/pci/if_aq.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/pci/if_aq.c diff -u src/sys/dev/pci/if_aq.c:1.4 src/sys/dev/pci/if_aq.c:1.5 --- src/sys/dev/pci/if_aq.c:1.4 Fri Jan 17 05:22:42 2020 +++ src/sys/dev/pci/if_aq.c Sat Jan 25 07:57:48 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_aq.c,v 1.4 2020/01/17 05:22:42 ryo Exp $ */ +/* $NetBSD: if_aq.c,v 1.5 2020/01/25 07:57:48 msaitoh Exp $ */ /** * aQuantia Corporation Network Driver @@ -62,7 +62,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_aq.c,v 1.4 2020/01/17 05:22:42 ryo Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_aq.c,v 1.5 2020/01/25 07:57:48 msaitoh Exp $"); #ifdef _KERNEL_OPT #include "opt_if_aq.h" @@ -209,7 +209,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_aq.c,v 1. /* AQ_GEN_INTR_MAP_REG[AQ_RINGS_NUM] 0x2180-0x2200 */ #define AQ_GEN_INTR_MAP_REG(i) (0x2180 + (i) * 4) -#define AQ_B0_ERR_INT 8 +#define AQ_B0_ERR_INT 8U #define AQ_INTR_CTRL_REG 0x2300 #define AQ_INTR_CTRL_IRQMODE __BITS(1,0) @@ -2581,7 +2581,7 @@ aq_set_mac_addr(struct aq_softc *sc, int } h = (enaddr[0] << 8) | (enaddr[1]); - l = (enaddr[2] << 24) | (enaddr[3] << 16) | + l = ((uint32_t)enaddr[2] << 24) | (enaddr[3] << 16) | (enaddr[4] << 8) | (enaddr[5]); /* disable, set, and enable */ @@ -3281,7 +3281,7 @@ aq_hw_init(struct aq_softc *sc) AQ_WRITE_REG(sc, AQ_INTR_AUTOMASK_REG, 0xffffffff); AQ_WRITE_REG(sc, AQ_GEN_INTR_MAP_REG(0), - ((AQ_B0_ERR_INT << 24) | (1 << 31)) | + ((AQ_B0_ERR_INT << 24) | (1U << 31)) | ((AQ_B0_ERR_INT << 16) | (1 << 23)) );