[OPW,kernel,RESEND,v3] staging: rtl8188eu: core: Improve cleanup code
diff mbox

Message ID 20141030154157.GA5302@kt-Inspiron-3542
State New, archived
Headers show

Commit Message

Tapasweni Pathak Oct. 30, 2014, 3:41 p.m. UTC
The code is restructured such that kfree(efuseTbl) is not called
if the allocation of efuseTbl and such that kfree(eFuseWord) is not
called if the allocation of eFuseWord has failed.

To accomplish this a new label eFuseWord_failed has been added.

Suggested by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Tapasweni Pathak <tapaswenipathak@gmail.com>
This patch was sent in a patchset. In the same patch null check
removal before kfree was done using Coccinelle script. Separated
both the changes in two separate patches and resending.
Suggested by: Julia Lawall <julia.lawall@lip6.fr>

 drivers/staging/rtl8188eu/core/rtw_efuse.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)


diff mbox

diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c b/drivers/staging/rtl8188eu/core/rtw_efuse.c
index d4c5b56..79a6991 100644
--- a/drivers/staging/rtl8188eu/core/rtw_efuse.c
+++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c
@@ -106,13 +106,13 @@  efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16 _size_byte, u8  *pbuf)
 	efuseTbl = kzalloc(EFUSE_MAP_LEN_88E, GFP_KERNEL);
 	if (efuseTbl == NULL) {
 		DBG_88E("%s: alloc efuseTbl fail!\n", __func__);
-		goto exit;
+		return;

 	eFuseWord = (u16 **)rtw_malloc2d(EFUSE_MAX_SECTION_88E, EFUSE_MAX_WORD_UNIT, sizeof(u16));
 	if (eFuseWord == NULL) {
 		DBG_88E("%s: alloc eFuseWord fail!\n", __func__);
-		goto exit;
+		goto eFuseWord_failed;

 	/*  0. Refresh efuse init map as all oxFF. */
@@ -210,10 +210,10 @@  efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16 _size_byte, u8  *pbuf)
 	/*  */

-	kfree(efuseTbl);
+	kfree(eFuseWord);

-	if (eFuseWord)
-		kfree(eFuseWord);
+	kfree(efuseTbl);

 static void efuse_read_phymap_from_txpktbuf(