Make ath_hal_eepromDetach() safer
authorproski <proski@0192ed92-7a03-0410-a25b-9323aeb14dbd>
Wed, 8 Apr 2009 22:25:50 +0000 (22:25 +0000)
committerproski <proski@0192ed92-7a03-0410-a25b-9323aeb14dbd>
Wed, 8 Apr 2009 22:25:50 +0000 (22:25 +0000)
Check that AH_PRIVATE(_ah)->ah_eepromDetach is not NULL before calling
it.  This fixes kernel oops in case if the attach function for the chip
fails before EEPROM support initialization and calls the corresponding
detach function.

git-svn-id: http://madwifi-project.org/svn/madwifi/trunk@3991 0192ed92-7a03-0410-a25b-9323aeb14dbd

ath_hal/ah_internal.h

index 17358afa62a9de528024c920babeb4c3279effe0..f876c8f5ee06ee62c50d0a891a11e44be2a79fac 100644 (file)
@@ -319,8 +319,10 @@ struct ath_hal_private {
 #define        ath_hal_disablePCIE(_ah) \
        (_ah)->ah_disablePCIE(_ah)
 
-#define        ath_hal_eepromDetach(_ah) \
-       AH_PRIVATE(_ah)->ah_eepromDetach(_ah)
+#define        ath_hal_eepromDetach(_ah) do { \
+       if (AH_PRIVATE(_ah)->ah_eepromDetach) \
+               AH_PRIVATE(_ah)->ah_eepromDetach(_ah); \
+} while (0)
 #define        ath_hal_eepromGet(_ah, _param, _val) \
        AH_PRIVATE(_ah)->ah_eepromGet(_ah, _param, _val)
 #define        ath_hal_eepromSet(_ah, _param, _val) \