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 error handling, to prevent kernel crashes wh...
details: https://anonhg.NetBSD.org/src/rev/4a1186abd663
branches: trunk
changeset: 454345:4a1186abd663
user: maxv <maxv%NetBSD.org@localhost>
date: Sat Sep 14 12:42:36 2019 +0000
description:
Fix error handling, to prevent kernel crashes when detaching an ural0
device.
Found with vHCI.
diffstat:
sys/dev/usb/if_ural.c | 10 ++++++++--
sys/dev/usb/if_uralvar.h | 7 ++++++-
2 files changed, 14 insertions(+), 3 deletions(-)
diffs (66 lines):
diff -r f4d480c4e0a7 -r 4a1186abd663 sys/dev/usb/if_ural.c
--- a/sys/dev/usb/if_ural.c Sat Sep 14 12:41:32 2019 +0000
+++ b/sys/dev/usb/if_ural.c Sat Sep 14 12:42:36 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ural.c,v 1.59 2019/05/05 03:17:54 mrg Exp $ */
+/* $NetBSD: if_ural.c,v 1.60 2019/09/14 12:42:36 maxv Exp $ */
/* $FreeBSD: /repoman/r/ncvs/src/sys/dev/usb/if_ural.c,v 1.40 2006/06/02 23:14:40 sam Exp $ */
/*-
@@ -24,7 +24,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ural.c,v 1.59 2019/05/05 03:17:54 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ural.c,v 1.60 2019/09/14 12:42:36 maxv Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -367,6 +367,7 @@
sc->sc_dev = self;
sc->sc_udev = uaa->uaa_device;
+ sc->sc_init_state = URAL_INIT_NONE;
aprint_naive("\n");
aprint_normal("\n");
@@ -513,6 +514,8 @@
ieee80211_announce(ic);
+ sc->sc_init_state = URAL_INIT_INITED;
+
usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev, sc->sc_dev);
if (!pmf_device_register(self, NULL, NULL))
@@ -529,6 +532,9 @@
struct ifnet *ifp = &sc->sc_if;
int s;
+ if (sc->sc_init_state < URAL_INIT_INITED)
+ return 0;
+
pmf_device_deregister(self);
s = splusb();
diff -r f4d480c4e0a7 -r 4a1186abd663 sys/dev/usb/if_uralvar.h
--- a/sys/dev/usb/if_uralvar.h Sat Sep 14 12:41:32 2019 +0000
+++ b/sys/dev/usb/if_uralvar.h Sat Sep 14 12:42:36 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_uralvar.h,v 1.12 2016/04/23 10:15:31 skrll Exp $ */
+/* $NetBSD: if_uralvar.h,v 1.13 2019/09/14 12:42:36 maxv Exp $ */
/* $OpenBSD: if_ralvar.h,v 1.2 2005/05/13 18:42:50 damien Exp $ */
/*-
@@ -74,6 +74,11 @@
device_t sc_dev;
struct ethercom sc_ec;
#define sc_if sc_ec.ec_if
+
+ enum {
+ URAL_INIT_NONE,
+ URAL_INIT_INITED
+ } sc_init_state;
struct ieee80211com sc_ic;
int (*sc_newstate)(struct ieee80211com *,
enum ieee80211_state, int);
Home |
Main Index |
Thread Index |
Old Index