Module Name: src Committed By: msaitoh Date: Wed Aug 5 03:42:11 UTC 2015
Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c ixgbe_osdep.h Log Message: Fix error path in ixgbe_attach() and ixgbe_detatch() to prevent panic. To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.32 src/sys/dev/pci/ixgbe/ixgbe.c cvs rdiff -u -r1.7 -r1.8 src/sys/dev/pci/ixgbe/ixgbe_osdep.h 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/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.31 src/sys/dev/pci/ixgbe/ixgbe.c:1.32 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.31 Mon Aug 3 05:43:01 2015 +++ src/sys/dev/pci/ixgbe/ixgbe.c Wed Aug 5 03:42:11 2015 @@ -59,7 +59,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ /*$FreeBSD: head/sys/dev/ixgbe/ixgbe.c 250108 2013-04-30 16:18:29Z luigi $*/ -/*$NetBSD: ixgbe.c,v 1.31 2015/08/03 05:43:01 msaitoh Exp $*/ +/*$NetBSD: ixgbe.c,v 1.32 2015/08/05 03:42:11 msaitoh Exp $*/ #include "opt_inet.h" #include "opt_inet6.h" @@ -510,6 +510,7 @@ ixgbe_attach(device_t parent, device_t d adapter->osdep.pc = pa->pa_pc; adapter->osdep.tag = pa->pa_tag; adapter->osdep.dmat = pa->pa_dmat; + adapter->osdep.attached = false; ent = ixgbe_lookup(pa); @@ -681,6 +682,7 @@ ixgbe_attach(device_t parent, device_t d ixgbe_netmap_attach(adapter); #endif /* DEV_NETMAP */ INIT_DEBUGOUT("ixgbe_attach: end"); + adapter->osdep.attached = true; return; err_late: ixgbe_free_transmit_structures(adapter); @@ -716,6 +718,8 @@ ixgbe_detach(device_t dev, int flags) u32 ctrl_ext; INIT_DEBUGOUT("ixgbe_detach: begin"); + if (adapter->osdep.attached == false) + return 0; #if NVLAN > 0 /* Make sure VLANs are not using driver */ @@ -2791,7 +2795,8 @@ ixgbe_free_pci_resources(struct adapter else (adapter->msix != 0) ? (rid = 1):(rid = 0); - pci_intr_disestablish(adapter->osdep.pc, adapter->osdep.intr); + if (adapter->osdep.intr != NULL) + pci_intr_disestablish(adapter->osdep.pc, adapter->osdep.intr); adapter->osdep.intr = NULL; #if defined(NETBSD_MSI_OR_MSIX) Index: src/sys/dev/pci/ixgbe/ixgbe_osdep.h diff -u src/sys/dev/pci/ixgbe/ixgbe_osdep.h:1.7 src/sys/dev/pci/ixgbe/ixgbe_osdep.h:1.8 --- src/sys/dev/pci/ixgbe/ixgbe_osdep.h:1.7 Fri Apr 24 07:00:51 2015 +++ src/sys/dev/pci/ixgbe/ixgbe_osdep.h Wed Aug 5 03:42:11 2015 @@ -31,7 +31,7 @@ ******************************************************************************/ /*$FreeBSD: head/sys/dev/ixgbe/ixgbe_osdep.h 247822 2013-03-04 23:07:40Z jfv $*/ -/*$NetBSD: ixgbe_osdep.h,v 1.7 2015/04/24 07:00:51 msaitoh Exp $*/ +/*$NetBSD: ixgbe_osdep.h,v 1.8 2015/08/05 03:42:11 msaitoh Exp $*/ #ifndef _IXGBE_OS_H_ #define _IXGBE_OS_H_ @@ -171,6 +171,7 @@ struct ixgbe_osdep device_t dev; pci_intr_handle_t ih; void *intr; + bool attached; }; /* These routines are needed by the shared code */