From 8a523a753aad0dc2ad043cd1007d273559f1e028 Mon Sep 17 00:00:00 2001 From: rodrigc Date: Mon, 24 Feb 2014 08:50:06 +0000 Subject: [PATCH] MFC r262142: 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 git-svn-id: svn://svn.freebsd.org/base/stable/10@262436 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- sys/dev/usb/net/usb_ethernet.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/dev/usb/net/usb_ethernet.c b/sys/dev/usb/net/usb_ethernet.c index 2f1795915..0be46014f 100644 --- a/sys/dev/usb/net/usb_ethernet.c +++ b/sys/dev/usb/net/usb_ethernet.c @@ -207,6 +207,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"); @@ -253,6 +254,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), @@ -266,6 +269,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); -- 2.45.0