Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pci Cast to uint32_t to avoid undefined behavior. Fo...



details:   https://anonhg.NetBSD.org/src/rev/8fd7e33e28e9
branches:  trunk
changeset: 847327:8fd7e33e28e9
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Wed Dec 18 13:25:00 2019 +0000

description:
Cast to uint32_t to avoid undefined behavior. Found by kUBSan.

diffstat:

 sys/dev/pci/if_alc.c |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (20 lines):

diff -r b942bf156fb6 -r 8fd7e33e28e9 sys/dev/pci/if_alc.c
--- a/sys/dev/pci/if_alc.c      Wed Dec 18 11:27:56 2019 +0000
+++ b/sys/dev/pci/if_alc.c      Wed Dec 18 13:25:00 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_alc.c,v 1.45 2019/12/01 08:16:49 msaitoh Exp $      */
+/*     $NetBSD: if_alc.c,v 1.46 2019/12/18 13:25:00 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>
@@ -2815,8 +2815,8 @@
 
        /* Reprogram the station address. */
        memcpy(eaddr, CLLADDR(ifp->if_sadl), sizeof(eaddr));
-       CSR_WRITE_4(sc, ALC_PAR0,
-           eaddr[2] << 24 | eaddr[3] << 16 | eaddr[4] << 8 | eaddr[5]);
+       CSR_WRITE_4(sc, ALC_PAR0, (uint32_t)eaddr[2] << 24
+           | eaddr[3] << 16 | eaddr[4] << 8 | eaddr[5]);
        CSR_WRITE_4(sc, ALC_PAR1, eaddr[0] << 8 | eaddr[1]);
        /*
         * Clear WOL status and disable all WOL feature as WOL



Home | Main Index | Thread Index | Old Index