wlan: Fix for unregistering IPv4 notifier rightly.
Correct the register and unregister sequence of IPv4
notifier block.
Change-Id: Ib8d77153adb2d71295e2a77a8e228ec55f967f2a
CRs-Fixed: 599742
diff --git a/CORE/HDD/src/wlan_hdd_early_suspend.c b/CORE/HDD/src/wlan_hdd_early_suspend.c
index 534ebb4..9a83efc 100644
--- a/CORE/HDD/src/wlan_hdd_early_suspend.c
+++ b/CORE/HDD/src/wlan_hdd_early_suspend.c
@@ -820,9 +820,17 @@
struct net_device *ndev = ifa->ifa_dev->dev;
hdd_adapter_t *pAdapter =
container_of(nb, struct hdd_adapter_s, ipv4_notifier);
-
+ hdd_context_t *pHddCtx;
+ int status;
if (pAdapter && pAdapter->dev == ndev)
{
+ pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
+ status = wlan_hdd_validate_context(pHddCtx);
+ if (0 != status)
+ {
+ hddLog(LOGE, FL("HDD context is invalid"));
+ return NOTIFY_DONE;
+ }
if ((in_dev = __in_dev_get_rtnl(pAdapter->dev)) != NULL)
{
for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
@@ -932,7 +940,7 @@
hddLog(VOS_TRACE_LEVEL_INFO, FL("IP Address is not assigned\n"));
}
- if (fenable == 1)
+ if (fenable == 1 && !pAdapter->ipv4_notifier_registered)
{
// Register IPv4 notifier to notify if any change in IP
// So that we can reconfigure the offload parameters
@@ -943,12 +951,22 @@
{
hddLog(LOGE, FL("Failed to register IPv4 notifier"));
}
+ else
+ {
+ hddLog(LOG1, FL("Registered IPv4 notifier"));
+ pAdapter->ipv4_notifier_registered = true;
+ }
}
return VOS_STATUS_SUCCESS;
}
else
{
- unregister_inetaddr_notifier(&pAdapter->ipv4_notifier);
+ if (pAdapter->ipv4_notifier_registered)
+ {
+ hddLog(LOG1, FL("Unregistered IPv4 notifier"));
+ unregister_inetaddr_notifier(&pAdapter->ipv4_notifier);
+ pAdapter->ipv4_notifier_registered = false;
+ }
vos_mem_zero((void *)&offLoadRequest, sizeof(tSirHostOffloadReq));
offLoadRequest.enableOrDisable = SIR_OFFLOAD_DISABLE;
offLoadRequest.offloadType = SIR_IPV4_ARP_REPLY_OFFLOAD;