Module Name:    src
Committed By:   maxv
Date:           Sat Sep 14 12:50:16 UTC 2019

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

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

Found with vHCI.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/dev/usb/udsbr.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/udsbr.c
diff -u src/sys/dev/usb/udsbr.c:1.27 src/sys/dev/usb/udsbr.c:1.28
--- src/sys/dev/usb/udsbr.c:1.27	Sun May  5 03:17:54 2019
+++ src/sys/dev/usb/udsbr.c	Sat Sep 14 12:50:16 2019
@@ -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 @@ udsbr_detach(device_t self, int flags)
 
 	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;
 }

Reply via email to