Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci Found by kUBSan:



details:   https://anonhg.NetBSD.org/src/rev/f656b64dda62
branches:  trunk
changeset: 1006713:f656b64dda62
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Sat Jan 25 07:57:48 2020 +0000

description:
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().

diffstat:

 sys/dev/pci/if_aq.c |  10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diffs (45 lines):

diff -r f18f066c6c5d -r f656b64dda62 sys/dev/pci/if_aq.c
--- a/sys/dev/pci/if_aq.c       Sat Jan 25 05:43:32 2020 +0000
+++ b/sys/dev/pci/if_aq.c       Sat Jan 25 07:57:48 2020 +0000
@@ -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 @@
 
 /* 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 @@
        }
 
        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_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))
        );
 



Home | Main Index | Thread Index | Old Index