[PATCH] staging: rtl8723au: fix potential leak in update_bcn_wps_ie()

From: Christian Engelmayer
Date: Thu May 01 2014 - 07:58:23 EST


Fix a potential leak in the error path of function update_bcn_wps_ie().
Make sure that allocated memory for 'pbackup_remainder_ie' is freed
upon return. Detected by Coverity - CID 1077718.

Signed-off-by: Christian Engelmayer <cengelma@xxxxxx>
---
Compile tested and applies against branch staging-next of tree
git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git
---
drivers/staging/rtl8723au/core/rtw_ap.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c
index 9b31412..f2c78a7 100644
--- a/drivers/staging/rtl8723au/core/rtw_ap.c
+++ b/drivers/staging/rtl8723au/core/rtw_ap.c
@@ -1276,7 +1276,7 @@ static void update_bcn_wps_ie(struct rtw_adapter *padapter)

pwps_ie_src = pmlmepriv->wps_beacon_ie;
if (pwps_ie_src == NULL)
- return;
+ goto exit;

wps_ielen = (uint)pwps_ie_src[1];/* to get ie data len */
if ((wps_offset+wps_ielen+2+remainder_ielen)<= MAX_IE_SZ)
@@ -1291,8 +1291,8 @@ static void update_bcn_wps_ie(struct rtw_adapter *padapter)
pnetwork->IELength = wps_offset + (wps_ielen+2) + remainder_ielen;
}

- if (pbackup_remainder_ie)
- kfree(pbackup_remainder_ie);
+exit:
+ kfree(pbackup_remainder_ie);
}

static void update_bcn_p2p_ie(struct rtw_adapter *padapter)
--
1.9.1

Attachment: signature.asc
Description: PGP signature