Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb Fix NULL deref, to prevent kernel crashes when d...



details:   https://anonhg.NetBSD.org/src/rev/a2c758391810
branches:  trunk
changeset: 965370:a2c758391810
user:      maxv <maxv%NetBSD.org@localhost>
date:      Sat Sep 14 12:50:16 2019 +0000

description:
Fix NULL deref, to prevent kernel crashes when detaching an udsbr0 device.

Found with vHCI.

diffstat:

 sys/dev/usb/udsbr.c |  9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diffs (30 lines):

diff -r 21418b138c29 -r a2c758391810 sys/dev/usb/udsbr.c
--- a/sys/dev/usb/udsbr.c       Sat Sep 14 12:48:51 2019 +0000
+++ b/sys/dev/usb/udsbr.c       Sat Sep 14 12:50:16 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: udsbr.c,v 1.27 2019/05/05 03:17:54 mrg Exp $   */
+/*     $NetBSD: udsbr.c,v 1.28 2019/09/14 12:50:16 maxv Exp $  */
 
 /*
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: udsbr.c,v 1.27 2019/05/05 03:17:54 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udsbr.c,v 1.28 2019/09/14 12:50:16 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -174,8 +174,9 @@
 
        if (sc->sc_child != NULL)
                rv = config_detach(sc->sc_child, flags);
-
-       usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev, sc->sc_dev);
+       if (sc->sc_udev != NULL)
+               usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev,
+                   sc->sc_dev);
 
        return rv;
 }



Home | Main Index | Thread Index | Old Index