Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pci Use unsigned to avoid undefined behavoir. Found ...



details:   https://anonhg.NetBSD.org/src/rev/0573dc324d4f
branches:  trunk
changeset: 967126:0573dc324d4f
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Sun Dec 01 08:16:49 2019 +0000

description:
Use unsigned to avoid undefined behavoir. Found by kUBSan.

diffstat:

 sys/dev/pci/if_age.c |  6 +++---
 sys/dev/pci/if_alc.c |  4 ++--
 sys/dev/pci/if_ale.c |  6 +++---
 3 files changed, 8 insertions(+), 8 deletions(-)

diffs (72 lines):

diff -r 62b4a238503f -r 0573dc324d4f sys/dev/pci/if_age.c
--- a/sys/dev/pci/if_age.c      Sun Dec 01 08:15:58 2019 +0000
+++ b/sys/dev/pci/if_age.c      Sun Dec 01 08:16:49 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_age.c,v 1.64 2019/11/21 09:12:30 msaitoh Exp $ */
+/*     $NetBSD: if_age.c,v 1.65 2019/12/01 08:16:49 msaitoh Exp $ */
 /*     $OpenBSD: if_age.c,v 1.1 2009/01/16 05:00:34 kevlo Exp $        */
 
 /*-
@@ -31,7 +31,7 @@
 /* Driver for Attansic Technology Corp. L1 Gigabit Ethernet. */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_age.c,v 1.64 2019/11/21 09:12:30 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_age.c,v 1.65 2019/12/01 08:16:49 msaitoh Exp $");
 
 #include "vlan.h"
 
@@ -2291,7 +2291,7 @@
                        goto update;
                }
                crc = ether_crc32_be(enm->enm_addrlo, ETHER_ADDR_LEN);
-               mchash[crc >> 31] |= 1 << ((crc >> 26) & 0x1f);
+               mchash[crc >> 31] |= 1U << ((crc >> 26) & 0x1f);
                ETHER_NEXT_MULTI(step, enm);
        }
        ETHER_UNLOCK(ec);
diff -r 62b4a238503f -r 0573dc324d4f sys/dev/pci/if_alc.c
--- a/sys/dev/pci/if_alc.c      Sun Dec 01 08:15:58 2019 +0000
+++ b/sys/dev/pci/if_alc.c      Sun Dec 01 08:16:49 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_alc.c,v 1.44 2019/11/21 09:12:30 msaitoh Exp $      */
+/*     $NetBSD: if_alc.c,v 1.45 2019/12/01 08:16:49 msaitoh Exp $      */
 /*     $OpenBSD: if_alc.c,v 1.1 2009/08/08 09:31:13 kevlo Exp $        */
 /*-
  * Copyright (c) 2009, Pyun YongHyeon <yongari%FreeBSD.org@localhost>
@@ -3459,7 +3459,7 @@
                        goto update;
                }
                crc = ether_crc32_be(enm->enm_addrlo, ETHER_ADDR_LEN);
-               mchash[crc >> 31] |= 1 << ((crc >> 26) & 0x1f);
+               mchash[crc >> 31] |= 1U << ((crc >> 26) & 0x1f);
                ETHER_NEXT_MULTI(step, enm);
        }
        ETHER_UNLOCK(ec);
diff -r 62b4a238503f -r 0573dc324d4f sys/dev/pci/if_ale.c
--- a/sys/dev/pci/if_ale.c      Sun Dec 01 08:15:58 2019 +0000
+++ b/sys/dev/pci/if_ale.c      Sun Dec 01 08:16:49 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_ale.c,v 1.36 2019/11/21 09:18:16 msaitoh Exp $      */
+/*     $NetBSD: if_ale.c,v 1.37 2019/12/01 08:16:49 msaitoh Exp $      */
 
 /*-
  * Copyright (c) 2008, Pyun YongHyeon <yongari%FreeBSD.org@localhost>
@@ -32,7 +32,7 @@
 /* Driver for Atheros AR8121/AR8113/AR8114 PCIe Ethernet. */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ale.c,v 1.36 2019/11/21 09:18:16 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ale.c,v 1.37 2019/12/01 08:16:49 msaitoh Exp $");
 
 #include "vlan.h"
 
@@ -2012,7 +2012,7 @@
                        goto update;
                }
                crc = ether_crc32_be(enm->enm_addrlo, ETHER_ADDR_LEN);
-               mchash[crc >> 31] |= 1 << ((crc >> 26) & 0x1f);
+               mchash[crc >> 31] |= 1U << ((crc >> 26) & 0x1f);
                ETHER_NEXT_MULTI(step, enm);
        }
        ETHER_UNLOCK(ec);



Home | Main Index | Thread Index | Old Index