Module Name:    src
Committed By:   maxv
Date:           Sat Sep 14 12:46:00 UTC 2019

Modified Files:
        src/sys/dev/usb: uipaq.c

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

Found with vHCI.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/dev/usb/uipaq.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/uipaq.c
diff -u src/sys/dev/usb/uipaq.c:1.25 src/sys/dev/usb/uipaq.c:1.26
--- src/sys/dev/usb/uipaq.c:1.25	Thu May  9 02:43:35 2019
+++ src/sys/dev/usb/uipaq.c	Sat Sep 14 12:46:00 2019
@@ -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 @@ uipaq_detach(device_t self, int flags)
 		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;
 }

Reply via email to