Module Name: src Committed By: msaitoh Date: Fri Oct 11 14:22:47 UTC 2019
Modified Files: src/sys/dev/ic: am79900reg.h src/sys/dev/pci: if_pcn.c Log Message: Use unsigned to avoid undefined behavior. Found by kUBSan. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/dev/ic/am79900reg.h cvs rdiff -u -r1.71 -r1.72 src/sys/dev/pci/if_pcn.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/ic/am79900reg.h diff -u src/sys/dev/ic/am79900reg.h:1.9 src/sys/dev/ic/am79900reg.h:1.10 --- src/sys/dev/ic/am79900reg.h:1.9 Mon Apr 28 20:23:49 2008 +++ src/sys/dev/ic/am79900reg.h Fri Oct 11 14:22:46 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: am79900reg.h,v 1.9 2008/04/28 20:23:49 martin Exp $ */ +/* $NetBSD: am79900reg.h,v 1.10 2019/10/11 14:22:46 msaitoh Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -96,7 +96,7 @@ struct leinit { }; /* Receive message descriptor 1 (rmd1_bits) */ -#define LE_R1_OWN (1<<31) /* LANCE owns the packet */ +#define LE_R1_OWN (1U<<31) /* LANCE owns the packet */ #define LE_R1_ERR (1<<30) /* error summary */ #define LE_R1_FRAM (1<<29) /* framing error */ #define LE_R1_OFLO (1<<28) /* overflow error */ @@ -111,7 +111,7 @@ struct leinit { "\20\40OWN\37ERR\36FRAM\35OFLO\34CRC\33BUFF\32STP\31ENP" /* Transmit message descriptor 1 (tmd1_bits) */ -#define LE_T1_OWN (1<<31) /* LANCE owns the packet */ +#define LE_T1_OWN (1U<<31) /* LANCE owns the packet */ #define LE_T1_ERR (1<<30) /* error summary */ #define LE_T1_ADD_FCS (1<<29) /* add FCS (PCnet-PCI) */ #define LE_T1_NO_FCS (1<<29) /* no FCS (ILACC) */ Index: src/sys/dev/pci/if_pcn.c diff -u src/sys/dev/pci/if_pcn.c:1.71 src/sys/dev/pci/if_pcn.c:1.72 --- src/sys/dev/pci/if_pcn.c:1.71 Tue May 28 07:41:49 2019 +++ src/sys/dev/pci/if_pcn.c Fri Oct 11 14:22:46 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: if_pcn.c,v 1.71 2019/05/28 07:41:49 msaitoh Exp $ */ +/* $NetBSD: if_pcn.c,v 1.72 2019/10/11 14:22:46 msaitoh Exp $ */ /* * Copyright (c) 2001 Wasabi Systems, Inc. @@ -65,7 +65,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_pcn.c,v 1.71 2019/05/28 07:41:49 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_pcn.c,v 1.72 2019/10/11 14:22:46 msaitoh Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -1708,12 +1708,13 @@ pcn_init(struct ifnet *ifp) sc->sc_initblock.init_rdra = htole32(PCN_CDRXADDR(sc, 0)); sc->sc_initblock.init_tdra = htole32(PCN_CDTXADDR(sc, 0)); sc->sc_initblock.init_mode = htole32(sc->sc_mode | - ((ffs(PCN_NTXDESC) - 1) << 28) | + (((uint32_t)ffs(PCN_NTXDESC) - 1) << 28) | ((ffs(PCN_NRXDESC) - 1) << 20)); /* Set the station address in the init block. */ sc->sc_initblock.init_padr[0] = htole32(enaddr[0] | - (enaddr[1] << 8) | (enaddr[2] << 16) | (enaddr[3] << 24)); + (enaddr[1] << 8) | (enaddr[2] << 16) | + ((uint32_t)enaddr[3] << 24)); sc->sc_initblock.init_padr[1] = htole32(enaddr[4] | (enaddr[5] << 8));