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/4f38171dc8d1
branches:  trunk
changeset: 965368:4f38171dc8d1
user:      maxv <maxv%NetBSD.org@localhost>
date:      Sat Sep 14 12:46:00 2019 +0000

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

Found with vHCI.

diffstat:

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

diffs (30 lines):

diff -r 4f9f255fe962 -r 4f38171dc8d1 sys/dev/usb/uipaq.c
--- a/sys/dev/usb/uipaq.c       Sat Sep 14 12:42:36 2019 +0000
+++ b/sys/dev/usb/uipaq.c       Sat Sep 14 12:46:00 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uipaq.c,v 1.25 2019/05/09 02:43:35 mrg Exp $   */
+/*     $NetBSD: uipaq.c,v 1.26 2019/09/14 12:46:00 maxv Exp $  */
 /*     $OpenBSD: uipaq.c,v 1.1 2005/06/17 23:50:33 deraadt Exp $       */
 
 /*
@@ -42,7 +42,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipaq.c,v 1.25 2019/05/09 02:43:35 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipaq.c,v 1.26 2019/09/14 12:46:00 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -398,8 +398,9 @@
                rv |= config_detach(sc->sc_subdev, flags);
                sc->sc_subdev = NULL;
        }
-
-       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