[WCNCR00158507] cfg80211: fix possible kernel panic after usb disconnects

[Description]
Not syncing at __cfg80211_disconnected.
Stack:
Unable to handle kernel NULL pointer dereference at virtual address
0000001b
PC is at mtk_cfg80211_del_key+0x74/0x100 [wlan_mt76x8_usb]
LR is at __cfg80211_disconnected+0x194/0x308 [cfg80211]

After USB disconnected, WiFi driver calls wlanRemove() to release
resources, but driver cannot estimate the time that kernel finishes
cfg80211_disconnected() processes. Sometimes mtk_cfg80211_del_key()
called by kernel is late, but wlanRemove() was finished,
then WiFi driver causes kernel panic.

Add a g_u4HaltFlag checker to avoid that case.

Test:
1. Sanity check: BT and WiFi scan/connection are OK
2. Ran overnight test pass

Change-Id: I4aa5fc640f11cf5bd91dbeab7a566562408a188a
CR-Id: WCNCR00158507
Feature: cfg80211
Signed-off-by: ZD Hu <zd.hu@mediatek.com>
(cherry picked from commit 092496de7300c33206be4601c4fd1c91bea16c3d)
1 file changed