net: wireless: bcmdhd: Fix country code map mem leak
Michael Hsu [Thu, 15 Oct 2015 02:14:52 +0000 (19:14 -0700)]
Free country code map buffer when adapter is removed.

Bug 200143482

Change-Id: Iab82b3b56ec07a99a3d3012b2931c51ddecbc502
Signed-off-by: Michael Hsu <mhsu@nvidia.com>
Reviewed-on: http://git-master/r/817916
(cherry picked from commit acdfc670eae8d581075e3ca41064ab0bb8540d71)
Reviewed-on: http://git-master/r/823728
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>

drivers/net/wireless/bcmdhd/dhd_linux_platdev.c

index 100712b..fb01ad2 100644 (file)
@@ -443,6 +443,15 @@ fail:
        adapter->n_country = 0;
        return -1;
 }
+
+static void wifi_platform_free_country_code_map(wifi_adapter_info_t *adapter)
+{
+       if (adapter->country_code_map) {
+               kfree(adapter->country_code_map);
+               adapter->country_code_map = NULL;
+       }
+       adapter->n_country = 0;
+}
 #endif
 
 static int wifi_plat_dev_drv_probe(struct platform_device *pdev)
@@ -521,6 +530,9 @@ static int wifi_plat_dev_drv_remove(struct platform_device *pdev)
 #endif /* BCMPCIE */
        }
 
+#ifdef NV_COUNTRY_CODE
+       wifi_platform_free_country_code_map(adapter);
+#endif
        sysedp_free_consumer(adapter->sysedpc);
        adapter->sysedpc = NULL;