Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb Don't assume mii is not null here. Some drivers ...



details:   https://anonhg.NetBSD.org/src/rev/7928bdfb1ee2
branches:  trunk
changeset: 466175:7928bdfb1ee2
user:      maya <maya%NetBSD.org@localhost>
date:      Sat Dec 14 15:40:43 2019 +0000

description:
Don't assume mii is not null here. Some drivers like urndis don't use
mii, so they always have mii == NULL.

ok riastradh. fixes PR kern/54762

diffstat:

 sys/dev/usb/usbnet.c |  13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diffs (41 lines):

diff -r 07722b2d3b4d -r 7928bdfb1ee2 sys/dev/usb/usbnet.c
--- a/sys/dev/usb/usbnet.c      Sat Dec 14 15:36:08 2019 +0000
+++ b/sys/dev/usb/usbnet.c      Sat Dec 14 15:40:43 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: usbnet.c,v 1.32 2019/12/03 05:01:58 riastradh Exp $    */
+/*     $NetBSD: usbnet.c,v 1.33 2019/12/14 15:40:43 maya Exp $ */
 
 /*
  * Copyright (c) 2019 Matthew R. Green
@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.32 2019/12/03 05:01:58 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.33 2019/12/14 15:40:43 maya Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -1188,7 +1188,6 @@
        struct mii_data * const mii = usbnet_mii(un);
 
        KASSERT(ifp != NULL);   /* embedded member */
-       KASSERT(mii != NULL);   /* only removed after dying=true and wait */
 
        unp->unp_refcnt++;
        mutex_exit(&unp->unp_lock);
@@ -1197,9 +1196,11 @@
                usbnet_watchdog(ifp);
 
        DPRINTFN(8, "mii %jx ifp %jx", (uintptr_t)mii, (uintptr_t)ifp, 0, 0);
-       mii_tick(mii);
-       if (!unp->unp_link)
-               (*mii->mii_statchg)(ifp);
+       if (mii) {
+               mii_tick(mii);
+               if (!unp->unp_link)
+                       (*mii->mii_statchg)(ifp);
+       }
 
        /* Call driver if requested. */
        uno_tick(un);



Home | Main Index | Thread Index | Old Index