Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pci Avoid undefined behavior in jme_mii_write(). Fou...



details:   https://anonhg.NetBSD.org/src/rev/8e0e69146867
branches:  trunk
changeset: 964573:8e0e69146867
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Wed Aug 07 15:29:02 2019 +0000

description:
Avoid undefined behavior in jme_mii_write(). Found by kUBSan.

diffstat:

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

diffs (27 lines):

diff -r 9bee4ac749f5 -r 8e0e69146867 sys/dev/pci/if_jme.c
--- a/sys/dev/pci/if_jme.c      Wed Aug 07 14:58:04 2019 +0000
+++ b/sys/dev/pci/if_jme.c      Wed Aug 07 15:29:02 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_jme.c,v 1.44 2019/07/09 08:46:59 msaitoh Exp $      */
+/*     $NetBSD: if_jme.c,v 1.45 2019/08/07 15:29:02 msaitoh Exp $      */
 
 /*
  * Copyright (c) 2008 Manuel Bouyer.  All rights reserved.
@@ -58,7 +58,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_jme.c,v 1.44 2019/07/09 08:46:59 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_jme.c,v 1.45 2019/08/07 15:29:02 msaitoh Exp $");
 
 
 #include <sys/param.h>
@@ -1021,7 +1021,7 @@
 
        bus_space_write_4(sc->jme_bt_mac, sc->jme_bh_mac, JME_SMI,
            SMI_OP_WRITE | SMI_OP_EXECUTE |
-           ((val << SMI_DATA_SHIFT) & SMI_DATA_MASK) |
+           (((uint32_t)val << SMI_DATA_SHIFT) & SMI_DATA_MASK) |
            SMI_PHY_ADDR(phy) | SMI_REG_ADDR(reg));
        for (i = JME_PHY_TIMEOUT / 10; i > 0; i--) {
                delay(10);



Home | Main Index | Thread Index | Old Index