ath6kl: Avoid null ptr dereference while printing reg domain pair
authorRaja Mani <rmani@qca.qualcomm.com>
Fri, 21 Sep 2012 09:38:53 +0000 (15:08 +0530)
committerKalle Valo <kvalo@qca.qualcomm.com>
Wed, 24 Oct 2012 08:49:50 +0000 (11:49 +0300)
Return value of ath6kl_get_regpair() is stored in 'regpair' in
ath6kl_wmi_regdomain_event() func and it's directly accessed
in the debug prints without checking for NULL value. There are
situation to get NULL pointer as a return value from
ath6kl_get_regpair() func. Fix this.

Found this on code review.

Signed-off-by: Raja Mani <rmani@qca.qualcomm.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
drivers/net/wireless/ath/ath6kl/wmi.c

index 68b46bda498ab3292c0593ae6d6712f7c7a08233..64b81fd554b3da41a1eec6c92c09ce6af401743e 100644 (file)
@@ -936,8 +936,12 @@ static void ath6kl_wmi_regdomain_event(struct wmi *wmi, u8 *datap, int len)
 
                regpair = ath6kl_get_regpair((u16) reg_code);
                country = ath6kl_regd_find_country_by_rd((u16) reg_code);
-               ath6kl_dbg(ATH6KL_DBG_WMI, "Regpair used: 0x%0x\n",
-                          regpair->regDmnEnum);
+               if (regpair)
+                       ath6kl_dbg(ATH6KL_DBG_WMI, "Regpair used: 0x%0x\n",
+                                  regpair->regDmnEnum);
+               else
+                       ath6kl_warn("Regpair not found reg_code 0x%0x\n",
+                                   reg_code);
        }
 
        if (country && wmi->parent_dev->wiphy_registered) {