attach fails early in case there's no firmware, but
athn_detach does ieee80211_ifdetach and if_detach
regardless of whether ifnet part got setup correctly
leading to a free of an unallocated memory and a
panic.

the following diff follows an established practice
in the other drivers and fixes the problem here.
tested on this device:

athn0 at uhub0 port 3 "NETGEAR WNA WNA1100" rev 2.00/1.08 addr 2
athn0: AR9271 rev 1 (1T1R), ROM rev 15, address 20:4e:7f:d9:65:2f

ok?

Index: athn.c
===================================================================
RCS file: /home/cvs/src/sys/dev/ic/athn.c,v
retrieving revision 1.74
diff -u -p -u -p -r1.74 athn.c
--- athn.c      20 Oct 2012 09:54:20 -0000      1.74
+++ athn.c      1 Nov 2012 16:33:53 -0000
@@ -396,8 +396,10 @@ athn_detach(struct athn_softc *sc)
        if (sc->eep != NULL)
                free(sc->eep, M_DEVBUF);
 
-       ieee80211_ifdetach(ifp);
-       if_detach(ifp);
+       if (ifp->if_softc != NULL) {
+               ieee80211_ifdetach(ifp);
+               if_detach(ifp);
+       }
 }
 
 #if NBPFILTER > 0

Reply via email to