diff options
author | rodrigc <rodrigc@FreeBSD.org> | 2014-02-18 01:20:26 +0000 |
---|---|---|
committer | rodrigc <rodrigc@FreeBSD.org> | 2014-02-18 01:20:26 +0000 |
commit | 3e3bcb42369fce6f32aa711d1cb579ee8f374b37 (patch) | |
tree | d191bdec6090d469533a9a8013a9ce09b46c9400 | |
parent | f9781635beb5be6e80e16325fa70abb820886a71 (diff) | |
download | FreeBSD-src-3e3bcb42369fce6f32aa711d1cb579ee8f374b37.zip FreeBSD-src-3e3bcb42369fce6f32aa711d1cb579ee8f374b37.tar.gz |
In ue_attach_post_task(), initialize curvnet to vnet0 before calling if_attach().
Before this patch, curvnet was NULL.
When the VIMAGE kernel option is enabled, this eliminates
kernel panics when USB ethernet devices are plugged in.
PR: 183835
Submitted by: Hiroo Oono <hiroo.ono at gmail dot com>
-rw-r--r-- | sys/dev/usb/net/usb_ethernet.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/sys/dev/usb/net/usb_ethernet.c b/sys/dev/usb/net/usb_ethernet.c index 1d3ae6e..d2b7f20 100644 --- a/sys/dev/usb/net/usb_ethernet.c +++ b/sys/dev/usb/net/usb_ethernet.c @@ -208,6 +208,7 @@ ue_attach_post_task(struct usb_proc_msg *_task) sysctl_ctx_init(&ue->ue_sysctl_ctx); error = 0; + CURVNET_SET_QUIET(vnet0); ifp = if_alloc(IFT_ETHER); if (ifp == NULL) { device_printf(ue->ue_dev, "could not allocate ifnet\n"); @@ -254,6 +255,8 @@ ue_attach_post_task(struct usb_proc_msg *_task) if (ifp->if_capabilities & IFCAP_VLAN_MTU) ifp->if_hdrlen = sizeof(struct ether_vlan_header); + CURVNET_RESTORE(); + snprintf(num, sizeof(num), "%u", ue->ue_unit); ue->ue_sysctl_oid = SYSCTL_ADD_NODE(&ue->ue_sysctl_ctx, &SYSCTL_NODE_CHILDREN(_net, ue), @@ -267,6 +270,7 @@ ue_attach_post_task(struct usb_proc_msg *_task) return; fail: + CURVNET_RESTORE(); free_unr(ueunit, ue->ue_unit); if (ue->ue_ifp != NULL) { if_free(ue->ue_ifp); |