summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authormaxv <maxv@NetBSD.org>2019-09-14 12:50:16 +0000
committermaxv <maxv@NetBSD.org>2019-09-14 12:50:16 +0000
commitfbc7cccea87e3a91df69cdd0a62c474aa508ca7e (patch)
treef161b37aa4d5ed7a0e40f5e0fd4c77bfe34755f2 /sys/dev
parent8e193fa061f3031f773bbc15791447e26dd4ccb6 (diff)
Fix NULL deref, to prevent kernel crashes when detaching an udsbr0 device.
Found with vHCI.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/usb/udsbr.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/sys/dev/usb/udsbr.c b/sys/dev/usb/udsbr.c
index f5ff5651f43..82d9e6a372e 100644
--- a/sys/dev/usb/udsbr.c
+++ b/sys/dev/usb/udsbr.c
@@ -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;
}