Bug 76723

Summary: Followup to my report
Product: Base System Reporter: Gene Stark <gene>
Component: kernAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 1.0-CURRENT   
Hardware: Any   
OS: Any   

Description Gene Stark 2005-01-26 19:40:28 UTC
 The patch I proposed in my original report exposed another bug
 in net/bpf.c, which I reported in PR-76410.  However, after making
 that additional patch, I found that there were still issues with if_xl.c,
 in that under the circumstances I described it would incorrectly called
 ether_ifdetach() without previously having called ether_ifattach().
 Examination of the code for ether_ifdetach() shows that it is not in
 any way, shape, or form intended to be called if ether_ifattach() had
 not previously been completed successfully.
 
 So, I added an additional flag to the if_xl driver to record whether
 ether_ifattach() was performed during initialization, so that calling
 ether_ifdetach() could be avoided during the failure unwind.
 This patch now successfully avoids panicking my laptop when the
 "cannot allocate memory for list buffers" condition occurs.
 Here are diffs for the full patch:
 
 
 Index: if_xl.c
 ===================================================================
 RCS file: /A/cvs/src/sys/pci/if_xl.c,v
 retrieving revision 1.72.2.29
 diff -c -r1.72.2.29 if_xl.c
 *** if_xl.c	19 Mar 2004 23:21:05 -0000	1.72.2.29
 --- if_xl.c	19 Jan 2005 14:00:58 -0000
 ***************
 *** 1770,1775 ****
 --- 1770,1776 ----
   	 * Call MI attach routine.
   	 */
   	ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
 + 	sc->xl_ether_ifattached = 1;
   
           /*
            * Tell the upper layer(s) we support long frames.
 ***************
 *** 1825,1831 ****
   
   	xl_reset(sc);
   	xl_stop(sc);
 ! 	ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
   	
   	if (sc->xl_miibus)
   		device_delete_child(dev, sc->xl_miibus);
 --- 1826,1833 ----
   
   	xl_reset(sc);
   	xl_stop(sc);
 ! 	if (sc->xl_ether_ifattached)
 ! 		ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
   	
   	if (sc->xl_miibus)
   		device_delete_child(dev, sc->xl_miibus);
 ***************
 *** 3274,3280 ****
   			sc->xl_cdata.xl_rx_chain[i].xl_mbuf = NULL;
   		}
   	}
 ! 	bzero(sc->xl_ldata.xl_rx_list, XL_RX_LIST_SZ);
   	/*
   	 * Free the TX list buffers.
   	 */
 --- 3276,3287 ----
   			sc->xl_cdata.xl_rx_chain[i].xl_mbuf = NULL;
   		}
   	}
 ! 	if(sc->xl_ldata.xl_rx_list != NULL)
 ! 	  bzero(sc->xl_ldata.xl_rx_list, XL_RX_LIST_SZ);
 ! 	else
 ! 	  printf("xl%d: xl_ldata.xl_rx_list == NULL in xl_stop!\n",
 ! 		 sc->xl_unit);
 ! 
   	/*
   	 * Free the TX list buffers.
   	 */
 ***************
 *** 3288,3294 ****
   			sc->xl_cdata.xl_tx_chain[i].xl_mbuf = NULL;
   		}
   	}
 ! 	bzero(sc->xl_ldata.xl_tx_list, XL_TX_LIST_SZ);
   
   	ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
   
 --- 3295,3305 ----
   			sc->xl_cdata.xl_tx_chain[i].xl_mbuf = NULL;
   		}
   	}
 ! 	if(sc->xl_ldata.xl_tx_list != NULL)
 ! 	  bzero(sc->xl_ldata.xl_tx_list, XL_TX_LIST_SZ);
 ! 	else
 ! 	  printf("xl%d: xl_ldata.xl_tx_list == NULL in xl_stop!\n",
 ! 		 sc->xl_unit);
   
   	ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
   
 
 
 Index: if_xlreg.h
 ===================================================================
 RCS file: /A/cvs/src/sys/pci/if_xlreg.h,v
 retrieving revision 1.25.2.8
 diff -r1.25.2.8 if_xlreg.h
 607a608
 > 	int			xl_ether_ifattached;
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2005-01-26 23:57:02 UTC
State Changed
From-To: open->closed

Misfiled followup to kern/76207 due to Subject line mangling. 


Comment 2 Mark Linimon freebsd_committer freebsd_triage 2005-01-26 23:57:02 UTC
Responsible Changed
From-To: gnats-admin->freebsd-bugs