diff mbox

[09/19] brcmfmac: fix NULL pointer access in brcmf_fweh_detach()

Message ID 1352947583-25341-10-git-send-email-frankyl@broadcom.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Franky Lin Nov. 15, 2012, 2:46 a.m. UTC
From: Hante Meuleman <meuleman@broadcom.com>

brcmf_fweh_detach can be called while ifp is already NULL, due to
init error. Fix NULL pointer access by checking ifp.

Reviewed-by: Arend Van Spriel <arend@broadcom.com>
Signed-off-by: Hante Meuleman <meuleman@broadcom.com>
Signed-off-by: Franky Lin <frankyl@broadcom.com>
---
 drivers/net/wireless/brcm80211/brcmfmac/fweh.c |   12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
diff mbox

Patch

diff --git a/drivers/net/wireless/brcm80211/brcmfmac/fweh.c b/drivers/net/wireless/brcm80211/brcmfmac/fweh.c
index e1521af..283acee 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/fweh.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/fweh.c
@@ -374,11 +374,13 @@  void brcmf_fweh_detach(struct brcmf_pub *drvr)
 	struct brcmf_if *ifp = drvr->iflist[0];
 	s8 eventmask[BRCMF_EVENTING_MASK_LEN];
 
-	/* clear all events */
-	memset(eventmask, 0, BRCMF_EVENTING_MASK_LEN);
-	(void)brcmf_fil_iovar_data_set(ifp, "event_msgs",
-				       eventmask, BRCMF_EVENTING_MASK_LEN);
-
+	if (ifp) {
+		/* clear all events */
+		memset(eventmask, 0, BRCMF_EVENTING_MASK_LEN);
+		(void)brcmf_fil_iovar_data_set(ifp, "event_msgs",
+					       eventmask,
+					       BRCMF_EVENTING_MASK_LEN);
+	}
 	/* cancel the worker */
 	cancel_work_sync(&fweh->event_work);
 	WARN_ON(!list_empty(&fweh->event_q));