Skip to contentSkip to conversation

Staging: rtl8723bs: core: rtw_cmd: Remove cast to pointer types in kfree

PATCH Superseded Srishti Sharma 2 participants 5 messages Oct 7, 2017 Staging

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: rtl8723bs: core: rtw_cmd: Remove cast to pointer types in kfree

The cast to pointer types in kfree is not needed and can be dropped. Done using the following semantic by coccinelle.

@r@
type T,P;
T* x;
@@

kfree(
-(P *)
x )

---
 drivers/staging/rtl8723bs/core/rtw_cmd.c | 58 ++++++++++++++++----------------
 1 file changed, 29 insertions(+), 29 deletions(-)
drivers/staging/rtl8723bs/core/rtw_cmd.c +29 -29
index 1843c44..e71e3ab 100644
@@ -408,7 +408,7 @@ void rtw_free_cmd_obj(struct cmd_obj *pcmd)
 	}
 
 	/* free cmd_obj */
-	kfree((unsigned char *)pcmd);
+	kfree(pcmd);
 }
 
 
@@ -619,7 +619,7 @@ u8 rtw_sitesurvey_cmd(struct adapter  *padapter, struct ndis_802_11_ssid *ssid,
 
 	psurveyPara = rtw_zmalloc(sizeof(struct sitesurvey_parm));
 	if (psurveyPara == NULL) {
-		kfree((unsigned char *) ph2c);
+		kfree(ph2c);
 		return _FAIL;
 	}
 
@@ -689,7 +689,7 @@ u8 rtw_setdatarate_cmd(struct adapter *padapter, u8 *rateset)
 
 	pbsetdataratepara = rtw_zmalloc(sizeof(struct setdatarate_parm));
 	if (pbsetdataratepara == NULL) {
-		kfree((u8 *) ph2c);
+		kfree(ph2c);
 		res = _FAIL;
 		goto exit;
 	}
@@ -707,7 +707,7 @@ void rtw_getbbrfreg_cmdrsp_callback(struct adapter *padapter,  struct cmd_obj *p
 {
 	/* rtw_free_cmd_obj(pcmd); */
 	kfree((unsigned char *) pcmd->parmbuf);
-	kfree((unsigned char *) pcmd);
+	kfree(pcmd);
 }
 
 u8 rtw_createbss_cmd(struct adapter  *padapter)
@@ -847,7 +847,7 @@ u8 rtw_joinbss_cmd(struct adapter  *padapter, struct wlan_network *pnetwork)
 	psecnetwork = (struct wlan_bssid_ex *)&psecuritypriv->sec_bss;
 	if (psecnetwork == NULL) {
 		if (pcmd != NULL)
-			kfree((unsigned char *)pcmd);
+			kfree(pcmd);
 
 		res = _FAIL;
 
@@ -955,7 +955,7 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms, bool enqueu
 		cmdobj = rtw_zmalloc(sizeof(*cmdobj));
 		if (cmdobj == NULL) {
 			res = _FAIL;
-			kfree((u8 *)param);
+			kfree(param);
 			goto exit;
 		}
 		init_h2fwcmd_w_parm_no_rsp(cmdobj, param, _DisConnect_CMD_);
@@ -964,7 +964,7 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms, bool enqueu
 		/* no need to enqueue, do the cmd hdl directly and free cmd parameter */
 		if (H2C_SUCCESS != disconnect_hdl(padapter, (u8 *)param))
 			res = _FAIL;
-		kfree((u8 *)param);
+		kfree(param);
 	}
 
 exit:
@@ -990,7 +990,7 @@ u8 rtw_setopmode_cmd(struct adapter  *padapter, enum NDIS_802_11_NETWORK_INFRAST
 	if (enqueue) {
 		ph2c = rtw_zmalloc(sizeof(struct cmd_obj));
 		if (ph2c == NULL) {
-			kfree((u8 *)psetop);
+			kfree(psetop);
 			res = _FAIL;
 			goto exit;
 		}
@@ -999,7 +999,7 @@ u8 rtw_setopmode_cmd(struct adapter  *padapter, enum NDIS_802_11_NETWORK_INFRAST
 		res = rtw_enqueue_cmd(pcmdpriv, ph2c);
 	} else{
 		setopmode_hdl(padapter, (u8 *)psetop);
-		kfree((u8 *)psetop);
+		kfree(psetop);
 	}
 exit:
 	return res;
@@ -1042,15 +1042,15 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 unicast_
 	if (enqueue) {
 		ph2c = rtw_zmalloc(sizeof(struct cmd_obj));
 		if (ph2c == NULL) {
-			kfree((u8 *) psetstakey_para);
+			kfree(psetstakey_para);
 			res = _FAIL;
 			goto exit;
 		}
 
 		psetstakey_rsp = rtw_zmalloc(sizeof(struct set_stakey_rsp));
 		if (psetstakey_rsp == NULL) {
-			kfree((u8 *) ph2c);
-			kfree((u8 *) psetstakey_para);
+			kfree(ph2c);
+			kfree(psetstakey_para);
 			res = _FAIL;
 			goto exit;
 		}
@@ -1061,7 +1061,7 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 unicast_
 		res = rtw_enqueue_cmd(pcmdpriv, ph2c);
 	} else{
 		set_stakey_hdl(padapter, (u8 *)psetstakey_para);
-		kfree((u8 *) psetstakey_para);
+		kfree(psetstakey_para);
 	}
 exit:
 	return res;
@@ -1091,15 +1091,15 @@ u8 rtw_clearstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 enqueu
 
 		psetstakey_para = rtw_zmalloc(sizeof(struct set_stakey_parm));
 		if (psetstakey_para == NULL) {
-			kfree((u8 *) ph2c);
+			kfree(ph2c);
 			res = _FAIL;
 			goto exit;
 		}
 
 		psetstakey_rsp = rtw_zmalloc(sizeof(struct set_stakey_rsp));
 		if (psetstakey_rsp == NULL) {
-			kfree((u8 *) ph2c);
-			kfree((u8 *) psetstakey_para);
+			kfree(ph2c);
+			kfree(psetstakey_para);
 			res = _FAIL;
 			goto exit;
 		}
@@ -1136,7 +1136,7 @@ u8 rtw_addbareq_cmd(struct adapter *padapter, u8 tid, u8 *addr)
 
 	paddbareq_parm = rtw_zmalloc(sizeof(struct addBaReq_parm));
 	if (paddbareq_parm == NULL) {
-		kfree((unsigned char *)ph2c);
+		kfree(ph2c);
 		res = _FAIL;
 		goto exit;
 	}
@@ -1170,7 +1170,7 @@ u8 rtw_reset_securitypriv_cmd(struct adapter *padapter)
 
 	pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
 	if (pdrvextra_cmd_parm == NULL) {
-		kfree((unsigned char *)ph2c);
+		kfree(ph2c);
 		res = _FAIL;
 		goto exit;
 	}
@@ -1205,7 +1205,7 @@ u8 rtw_free_assoc_resources_cmd(struct adapter *padapter)
 
 	pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
 	if (pdrvextra_cmd_parm == NULL) {
-		kfree((unsigned char *)ph2c);
+		kfree(ph2c);
 		res = _FAIL;
 		goto exit;
 	}
@@ -1241,7 +1241,7 @@ u8 rtw_dynamic_chk_wk_cmd(struct adapter *padapter)
 
 	pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
 	if (pdrvextra_cmd_parm == NULL) {
-		kfree((unsigned char *)ph2c);
+		kfree(ph2c);
 		res = _FAIL;
 		goto exit;
 	}
@@ -1294,7 +1294,7 @@ u8 rtw_set_chplan_cmd(struct adapter *padapter, u8 chplan, u8 enqueue, u8 swconf
 		/* need enqueue, prepare cmd_obj and enqueue */
 		pcmdobj = rtw_zmalloc(sizeof(struct cmd_obj));
 		if (pcmdobj == NULL) {
-			kfree((u8 *)setChannelPlan_param);
+			kfree(setChannelPlan_param);
 			res = _FAIL;
 			goto exit;
 		}
@@ -1306,7 +1306,7 @@ u8 rtw_set_chplan_cmd(struct adapter *padapter, u8 chplan, u8 enqueue, u8 swconf
 		if (H2C_SUCCESS != set_chplan_hdl(padapter, (unsigned char *)setChannelPlan_param))
 			res = _FAIL;
 
-		kfree((u8 *)setChannelPlan_param);
+		kfree(setChannelPlan_param);
 	}
 
 	/* do something based on res... */
@@ -1561,7 +1561,7 @@ u8 rtw_lps_ctrl_wk_cmd(struct adapter *padapter, u8 lps_ctrl_type, u8 enqueue)
 
 		pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
 		if (pdrvextra_cmd_parm == NULL) {
-			kfree((unsigned char *)ph2c);
+			kfree(ph2c);
 			res = _FAIL;
 			goto exit;
 		}
@@ -1603,7 +1603,7 @@ u8 rtw_dm_in_lps_wk_cmd(struct adapter *padapter)
 
 	pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
 	if (pdrvextra_cmd_parm == NULL) {
-		kfree((unsigned char *)ph2c);
+		kfree(ph2c);
 		res = _FAIL;
 		goto exit;
 	}
@@ -1676,7 +1676,7 @@ u8 rtw_dm_ra_mask_wk_cmd(struct adapter *padapter, u8 *psta)
 
 	pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
 	if (pdrvextra_cmd_parm == NULL) {
-		kfree((unsigned char *)ph2c);
+		kfree(ph2c);
 		res = _FAIL;
 		goto exit;
 	}
@@ -1727,7 +1727,7 @@ u8 rtw_ps_cmd(struct adapter *padapter)
 
 	pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
 	if (pdrvextra_cmd_parm == NULL) {
-		kfree((unsigned char *)ppscmd);
+		kfree(ppscmd);
 		res = _FAIL;
 		goto exit;
 	}
@@ -1799,7 +1799,7 @@ u8 rtw_chk_hi_queue_cmd(struct adapter *padapter)
 
 	pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
 	if (pdrvextra_cmd_parm == NULL) {
-		kfree((unsigned char *)ph2c);
+		kfree(ph2c);
 		res = _FAIL;
 		goto exit;
 	}
@@ -1898,7 +1898,7 @@ u8 rtw_c2h_packet_wk_cmd(struct adapter *padapter, u8 *pbuf, u16 length)
 
 	pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
 	if (pdrvextra_cmd_parm == NULL) {
-		kfree((u8 *)ph2c);
+		kfree(ph2c);
 		res = _FAIL;
 		goto exit;
 	}
@@ -1933,7 +1933,7 @@ u8 rtw_c2h_wk_cmd(struct adapter *padapter, u8 *c2h_evt)
 
 	pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
 	if (pdrvextra_cmd_parm == NULL) {
-		kfree((u8 *)ph2c);
+		kfree(ph2c);
 		res = _FAIL;
 		goto exit;
 	}
Signature · 1 line
2.7.4
#1 lore raw
Quoted 49 lines · Srishti Sharma

The cast to pointer types in kfree is not needed and can be dropped. Done using the following semantic by coccinelle.

@r@
type T,P;
T* x;
@@

kfree(
-(P *)
x )

---
 drivers/staging/rtl8723bs/core/rtw_cmd.c | 58 ++++++++++++++++----------------
 1 file changed, 29 insertions(+), 29 deletions(-)
drivers/staging/rtl8723bs/core/rtw_cmd.c +3 -3
index 1843c44..e71e3ab 100644
@@ -408,7 +408,7 @@ void rtw_free_cmd_obj(struct cmd_obj *pcmd)
 	}
 
 	/* free cmd_obj */
-	kfree((unsigned char *)pcmd);
+	kfree(pcmd);
 }
 
 
@@ -619,7 +619,7 @@ u8 rtw_sitesurvey_cmd(struct adapter  *padapter, struct ndis_802_11_ssid *ssid,
 
 	psurveyPara = rtw_zmalloc(sizeof(struct sitesurvey_parm));
 	if (psurveyPara == NULL) {
-		kfree((unsigned char *) ph2c);
+		kfree(ph2c);
 		return _FAIL;
 	}
 
@@ -689,7 +689,7 @@ u8 rtw_setdatarate_cmd(struct adapter *padapter, u8 *rateset)
 
 	pbsetdataratepara = rtw_zmalloc(sizeof(struct setdatarate_parm));
 	if (pbsetdataratepara == NULL) {
-		kfree((u8 *) ph2c);
+		kfree(ph2c);
 		res = _FAIL;
 		goto exit;
 	}

drivers/staging/rtl8723bs/core/rtw_cmd.c void rtw_getbbrfreg_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *p · line 709

Quoted 3 lines
drivers/staging/rtl8723bs/core/rtw_cmd.c +0 -0
@@ -707,7 +707,7 @@ void rtw_getbbrfreg_cmdrsp_callback(struct adapter *padapter,  struct cmd_obj *p
 {
 	/* rtw_free_cmd_obj(pcmd); */
 	kfree((unsigned char *) pcmd->parmbuf);

This case didn't get updated, probably because Coccinelle didn't have access to enough type information. Try rerunning with --all-includes or --recursive-includes. You may also need to give some include path information (-I argument).

julia

Quoted 224 lines
drivers/staging/rtl8723bs/core/rtw_cmd.c +26 -27
-	kfree((unsigned char *) pcmd);
+	kfree(pcmd);
 }
 
 u8 rtw_createbss_cmd(struct adapter  *padapter)
@@ -847,7 +847,7 @@ u8 rtw_joinbss_cmd(struct adapter  *padapter, struct wlan_network *pnetwork)
 	psecnetwork = (struct wlan_bssid_ex *)&psecuritypriv->sec_bss;
 	if (psecnetwork == NULL) {
 		if (pcmd != NULL)
-			kfree((unsigned char *)pcmd);
+			kfree(pcmd);
 
 		res = _FAIL;
 
@@ -955,7 +955,7 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms, bool enqueu
 		cmdobj = rtw_zmalloc(sizeof(*cmdobj));
 		if (cmdobj == NULL) {
 			res = _FAIL;
-			kfree((u8 *)param);
+			kfree(param);
 			goto exit;
 		}
 		init_h2fwcmd_w_parm_no_rsp(cmdobj, param, _DisConnect_CMD_);
@@ -964,7 +964,7 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms, bool enqueu
 		/* no need to enqueue, do the cmd hdl directly and free cmd parameter */
 		if (H2C_SUCCESS != disconnect_hdl(padapter, (u8 *)param))
 			res = _FAIL;
-		kfree((u8 *)param);
+		kfree(param);
 	}
 
 exit:
@@ -990,7 +990,7 @@ u8 rtw_setopmode_cmd(struct adapter  *padapter, enum NDIS_802_11_NETWORK_INFRAST
 	if (enqueue) {
 		ph2c = rtw_zmalloc(sizeof(struct cmd_obj));
 		if (ph2c == NULL) {
-			kfree((u8 *)psetop);
+			kfree(psetop);
 			res = _FAIL;
 			goto exit;
 		}
@@ -999,7 +999,7 @@ u8 rtw_setopmode_cmd(struct adapter  *padapter, enum NDIS_802_11_NETWORK_INFRAST
 		res = rtw_enqueue_cmd(pcmdpriv, ph2c);
 	} else{
 		setopmode_hdl(padapter, (u8 *)psetop);
-		kfree((u8 *)psetop);
+		kfree(psetop);
 	}
 exit:
 	return res;
@@ -1042,15 +1042,15 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 unicast_
 	if (enqueue) {
 		ph2c = rtw_zmalloc(sizeof(struct cmd_obj));
 		if (ph2c == NULL) {
-			kfree((u8 *) psetstakey_para);
+			kfree(psetstakey_para);
 			res = _FAIL;
 			goto exit;
 		}
 
 		psetstakey_rsp = rtw_zmalloc(sizeof(struct set_stakey_rsp));
 		if (psetstakey_rsp == NULL) {
-			kfree((u8 *) ph2c);
-			kfree((u8 *) psetstakey_para);
+			kfree(ph2c);
+			kfree(psetstakey_para);
 			res = _FAIL;
 			goto exit;
 		}
@@ -1061,7 +1061,7 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 unicast_
 		res = rtw_enqueue_cmd(pcmdpriv, ph2c);
 	} else{
 		set_stakey_hdl(padapter, (u8 *)psetstakey_para);
-		kfree((u8 *) psetstakey_para);
+		kfree(psetstakey_para);
 	}
 exit:
 	return res;
@@ -1091,15 +1091,15 @@ u8 rtw_clearstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 enqueu
 
 		psetstakey_para = rtw_zmalloc(sizeof(struct set_stakey_parm));
 		if (psetstakey_para == NULL) {
-			kfree((u8 *) ph2c);
+			kfree(ph2c);
 			res = _FAIL;
 			goto exit;
 		}
 
 		psetstakey_rsp = rtw_zmalloc(sizeof(struct set_stakey_rsp));
 		if (psetstakey_rsp == NULL) {
-			kfree((u8 *) ph2c);
-			kfree((u8 *) psetstakey_para);
+			kfree(ph2c);
+			kfree(psetstakey_para);
 			res = _FAIL;
 			goto exit;
 		}
@@ -1136,7 +1136,7 @@ u8 rtw_addbareq_cmd(struct adapter *padapter, u8 tid, u8 *addr)
 
 	paddbareq_parm = rtw_zmalloc(sizeof(struct addBaReq_parm));
 	if (paddbareq_parm == NULL) {
-		kfree((unsigned char *)ph2c);
+		kfree(ph2c);
 		res = _FAIL;
 		goto exit;
 	}
@@ -1170,7 +1170,7 @@ u8 rtw_reset_securitypriv_cmd(struct adapter *padapter)
 
 	pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
 	if (pdrvextra_cmd_parm == NULL) {
-		kfree((unsigned char *)ph2c);
+		kfree(ph2c);
 		res = _FAIL;
 		goto exit;
 	}
@@ -1205,7 +1205,7 @@ u8 rtw_free_assoc_resources_cmd(struct adapter *padapter)
 
 	pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
 	if (pdrvextra_cmd_parm == NULL) {
-		kfree((unsigned char *)ph2c);
+		kfree(ph2c);
 		res = _FAIL;
 		goto exit;
 	}
@@ -1241,7 +1241,7 @@ u8 rtw_dynamic_chk_wk_cmd(struct adapter *padapter)
 
 	pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
 	if (pdrvextra_cmd_parm == NULL) {
-		kfree((unsigned char *)ph2c);
+		kfree(ph2c);
 		res = _FAIL;
 		goto exit;
 	}
@@ -1294,7 +1294,7 @@ u8 rtw_set_chplan_cmd(struct adapter *padapter, u8 chplan, u8 enqueue, u8 swconf
 		/* need enqueue, prepare cmd_obj and enqueue */
 		pcmdobj = rtw_zmalloc(sizeof(struct cmd_obj));
 		if (pcmdobj == NULL) {
-			kfree((u8 *)setChannelPlan_param);
+			kfree(setChannelPlan_param);
 			res = _FAIL;
 			goto exit;
 		}
@@ -1306,7 +1306,7 @@ u8 rtw_set_chplan_cmd(struct adapter *padapter, u8 chplan, u8 enqueue, u8 swconf
 		if (H2C_SUCCESS != set_chplan_hdl(padapter, (unsigned char *)setChannelPlan_param))
 			res = _FAIL;
 
-		kfree((u8 *)setChannelPlan_param);
+		kfree(setChannelPlan_param);
 	}
 
 	/* do something based on res... */
@@ -1561,7 +1561,7 @@ u8 rtw_lps_ctrl_wk_cmd(struct adapter *padapter, u8 lps_ctrl_type, u8 enqueue)
 
 		pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
 		if (pdrvextra_cmd_parm == NULL) {
-			kfree((unsigned char *)ph2c);
+			kfree(ph2c);
 			res = _FAIL;
 			goto exit;
 		}
@@ -1603,7 +1603,7 @@ u8 rtw_dm_in_lps_wk_cmd(struct adapter *padapter)
 
 	pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
 	if (pdrvextra_cmd_parm == NULL) {
-		kfree((unsigned char *)ph2c);
+		kfree(ph2c);
 		res = _FAIL;
 		goto exit;
 	}
@@ -1676,7 +1676,7 @@ u8 rtw_dm_ra_mask_wk_cmd(struct adapter *padapter, u8 *psta)
 
 	pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
 	if (pdrvextra_cmd_parm == NULL) {
-		kfree((unsigned char *)ph2c);
+		kfree(ph2c);
 		res = _FAIL;
 		goto exit;
 	}
@@ -1727,7 +1727,7 @@ u8 rtw_ps_cmd(struct adapter *padapter)
 
 	pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
 	if (pdrvextra_cmd_parm == NULL) {
-		kfree((unsigned char *)ppscmd);
+		kfree(ppscmd);
 		res = _FAIL;
 		goto exit;
 	}
@@ -1799,7 +1799,7 @@ u8 rtw_chk_hi_queue_cmd(struct adapter *padapter)
 
 	pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
 	if (pdrvextra_cmd_parm == NULL) {
-		kfree((unsigned char *)ph2c);
+		kfree(ph2c);
 		res = _FAIL;
 		goto exit;
 	}
@@ -1898,7 +1898,7 @@ u8 rtw_c2h_packet_wk_cmd(struct adapter *padapter, u8 *pbuf, u16 length)
 
 	pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
 	if (pdrvextra_cmd_parm == NULL) {
-		kfree((u8 *)ph2c);
+		kfree(ph2c);
 		res = _FAIL;
 		goto exit;
 	}
@@ -1933,7 +1933,7 @@ u8 rtw_c2h_wk_cmd(struct adapter *padapter, u8 *c2h_evt)
 
 	pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
 	if (pdrvextra_cmd_parm == NULL) {
-		kfree((u8 *)ph2c);
+		kfree(ph2c);
 		res = _FAIL;
 		goto exit;
 	}
--

2.7.4

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/1507380884-10906-1-git-send-email-srishtishar%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

#2 lore raw
Quoted 45 lines · Julia Lawall
Quoted 41 lines · Srishti Sharma

The cast to pointer types in kfree is not needed and can be dropped. Done using the following semantic by coccinelle.

@r@
type T,P;
T* x;
@@

kfree(
-(P *)
x )

---
 drivers/staging/rtl8723bs/core/rtw_cmd.c | 58 ++++++++++++++++----------------
 1 file changed, 29 insertions(+), 29 deletions(-)
drivers/staging/rtl8723bs/core/rtw_cmd.c +2 -2
index 1843c44..e71e3ab 100644
@@ -408,7 +408,7 @@ void rtw_free_cmd_obj(struct cmd_obj *pcmd)
      }
 
      /* free cmd_obj */
-     kfree((unsigned char *)pcmd);
+     kfree(pcmd);
 }
 
 
@@ -619,7 +619,7 @@ u8 rtw_sitesurvey_cmd(struct adapter  *padapter, struct ndis_802_11_ssid *ssid,
 
      psurveyPara = rtw_zmalloc(sizeof(struct sitesurvey_parm));
      if (psurveyPara == NULL) {
-             kfree((unsigned char *) ph2c);
+             kfree(ph2c);
              return _FAIL;
      }
 
@@ -689,7 +689,7 @@ u8 rtw_setdatarate_cmd(struct adapter *padapter, u8 *rateset)
 
Quoted 16 lines

drivers/staging/rtl8723bs/core/rtw_cmd.c void rtw_getbbrfreg_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *p · line 709

Quoted 11 lines
drivers/staging/rtl8723bs/core/rtw_cmd.c +1 -1
      pbsetdataratepara = rtw_zmalloc(sizeof(struct setdatarate_parm));
      if (pbsetdataratepara == NULL) {
-             kfree((u8 *) ph2c);
+             kfree(ph2c);
              res = _FAIL;
              goto exit;
      }
@@ -707,7 +707,7 @@ void rtw_getbbrfreg_cmdrsp_callback(struct adapter *padapter,  struct cmd_obj *p
 {
      /* rtw_free_cmd_obj(pcmd); */
      kfree((unsigned char *) pcmd->parmbuf);

This case didn't get updated, probably because Coccinelle didn't have access to enough type information. Try rerunning with --all-includes or --recursive-includes. You may also need to give some include path information (-I argument).

I tried doing this but it is still not detecting this particular case, for the include path I gave the path of the directory which contains the header file in which struct cmd_obj is defined.

Regards,
Srishti

Quoted 227 lines

julia

Quoted 224 lines
drivers/staging/rtl8723bs/core/rtw_cmd.c +26 -27
-     kfree((unsigned char *) pcmd);
+     kfree(pcmd);
 }
 
 u8 rtw_createbss_cmd(struct adapter  *padapter)
@@ -847,7 +847,7 @@ u8 rtw_joinbss_cmd(struct adapter  *padapter, struct wlan_network *pnetwork)
      psecnetwork = (struct wlan_bssid_ex *)&psecuritypriv->sec_bss;
      if (psecnetwork == NULL) {
              if (pcmd != NULL)
-                     kfree((unsigned char *)pcmd);
+                     kfree(pcmd);
 
              res = _FAIL;
 
@@ -955,7 +955,7 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms, bool enqueu
              cmdobj = rtw_zmalloc(sizeof(*cmdobj));
              if (cmdobj == NULL) {
                      res = _FAIL;
-                     kfree((u8 *)param);
+                     kfree(param);
                      goto exit;
              }
              init_h2fwcmd_w_parm_no_rsp(cmdobj, param, _DisConnect_CMD_);
@@ -964,7 +964,7 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms, bool enqueu
              /* no need to enqueue, do the cmd hdl directly and free cmd parameter */
              if (H2C_SUCCESS != disconnect_hdl(padapter, (u8 *)param))
                      res = _FAIL;
-             kfree((u8 *)param);
+             kfree(param);
      }
 
 exit:
@@ -990,7 +990,7 @@ u8 rtw_setopmode_cmd(struct adapter  *padapter, enum NDIS_802_11_NETWORK_INFRAST
      if (enqueue) {
              ph2c = rtw_zmalloc(sizeof(struct cmd_obj));
              if (ph2c == NULL) {
-                     kfree((u8 *)psetop);
+                     kfree(psetop);
                      res = _FAIL;
                      goto exit;
              }
@@ -999,7 +999,7 @@ u8 rtw_setopmode_cmd(struct adapter  *padapter, enum NDIS_802_11_NETWORK_INFRAST
              res = rtw_enqueue_cmd(pcmdpriv, ph2c);
      } else{
              setopmode_hdl(padapter, (u8 *)psetop);
-             kfree((u8 *)psetop);
+             kfree(psetop);
      }
 exit:
      return res;
@@ -1042,15 +1042,15 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 unicast_
      if (enqueue) {
              ph2c = rtw_zmalloc(sizeof(struct cmd_obj));
              if (ph2c == NULL) {
-                     kfree((u8 *) psetstakey_para);
+                     kfree(psetstakey_para);
                      res = _FAIL;
                      goto exit;
              }
 
              psetstakey_rsp = rtw_zmalloc(sizeof(struct set_stakey_rsp));
              if (psetstakey_rsp == NULL) {
-                     kfree((u8 *) ph2c);
-                     kfree((u8 *) psetstakey_para);
+                     kfree(ph2c);
+                     kfree(psetstakey_para);
                      res = _FAIL;
                      goto exit;
              }
@@ -1061,7 +1061,7 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 unicast_
              res = rtw_enqueue_cmd(pcmdpriv, ph2c);
      } else{
              set_stakey_hdl(padapter, (u8 *)psetstakey_para);
-             kfree((u8 *) psetstakey_para);
+             kfree(psetstakey_para);
      }
 exit:
      return res;
@@ -1091,15 +1091,15 @@ u8 rtw_clearstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 enqueu
 
              psetstakey_para = rtw_zmalloc(sizeof(struct set_stakey_parm));
              if (psetstakey_para == NULL) {
-                     kfree((u8 *) ph2c);
+                     kfree(ph2c);
                      res = _FAIL;
                      goto exit;
              }
 
              psetstakey_rsp = rtw_zmalloc(sizeof(struct set_stakey_rsp));
              if (psetstakey_rsp == NULL) {
-                     kfree((u8 *) ph2c);
-                     kfree((u8 *) psetstakey_para);
+                     kfree(ph2c);
+                     kfree(psetstakey_para);
                      res = _FAIL;
                      goto exit;
              }
@@ -1136,7 +1136,7 @@ u8 rtw_addbareq_cmd(struct adapter *padapter, u8 tid, u8 *addr)
 
      paddbareq_parm = rtw_zmalloc(sizeof(struct addBaReq_parm));
      if (paddbareq_parm == NULL) {
-             kfree((unsigned char *)ph2c);
+             kfree(ph2c);
              res = _FAIL;
              goto exit;
      }
@@ -1170,7 +1170,7 @@ u8 rtw_reset_securitypriv_cmd(struct adapter *padapter)
 
      pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
      if (pdrvextra_cmd_parm == NULL) {
-             kfree((unsigned char *)ph2c);
+             kfree(ph2c);
              res = _FAIL;
              goto exit;
      }
@@ -1205,7 +1205,7 @@ u8 rtw_free_assoc_resources_cmd(struct adapter *padapter)
 
      pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
      if (pdrvextra_cmd_parm == NULL) {
-             kfree((unsigned char *)ph2c);
+             kfree(ph2c);
              res = _FAIL;
              goto exit;
      }
@@ -1241,7 +1241,7 @@ u8 rtw_dynamic_chk_wk_cmd(struct adapter *padapter)
 
      pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
      if (pdrvextra_cmd_parm == NULL) {
-             kfree((unsigned char *)ph2c);
+             kfree(ph2c);
              res = _FAIL;
              goto exit;
      }
@@ -1294,7 +1294,7 @@ u8 rtw_set_chplan_cmd(struct adapter *padapter, u8 chplan, u8 enqueue, u8 swconf
              /* need enqueue, prepare cmd_obj and enqueue */
              pcmdobj = rtw_zmalloc(sizeof(struct cmd_obj));
              if (pcmdobj == NULL) {
-                     kfree((u8 *)setChannelPlan_param);
+                     kfree(setChannelPlan_param);
                      res = _FAIL;
                      goto exit;
              }
@@ -1306,7 +1306,7 @@ u8 rtw_set_chplan_cmd(struct adapter *padapter, u8 chplan, u8 enqueue, u8 swconf
              if (H2C_SUCCESS != set_chplan_hdl(padapter, (unsigned char *)setChannelPlan_param))
                      res = _FAIL;
 
-             kfree((u8 *)setChannelPlan_param);
+             kfree(setChannelPlan_param);
      }
 
      /* do something based on res... */
@@ -1561,7 +1561,7 @@ u8 rtw_lps_ctrl_wk_cmd(struct adapter *padapter, u8 lps_ctrl_type, u8 enqueue)
 
              pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
              if (pdrvextra_cmd_parm == NULL) {
-                     kfree((unsigned char *)ph2c);
+                     kfree(ph2c);
                      res = _FAIL;
                      goto exit;
              }
@@ -1603,7 +1603,7 @@ u8 rtw_dm_in_lps_wk_cmd(struct adapter *padapter)
 
      pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
      if (pdrvextra_cmd_parm == NULL) {
-             kfree((unsigned char *)ph2c);
+             kfree(ph2c);
              res = _FAIL;
              goto exit;
      }
@@ -1676,7 +1676,7 @@ u8 rtw_dm_ra_mask_wk_cmd(struct adapter *padapter, u8 *psta)
 
      pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
      if (pdrvextra_cmd_parm == NULL) {
-             kfree((unsigned char *)ph2c);
+             kfree(ph2c);
              res = _FAIL;
              goto exit;
      }
@@ -1727,7 +1727,7 @@ u8 rtw_ps_cmd(struct adapter *padapter)
 
      pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
      if (pdrvextra_cmd_parm == NULL) {
-             kfree((unsigned char *)ppscmd);
+             kfree(ppscmd);
              res = _FAIL;
              goto exit;
      }
@@ -1799,7 +1799,7 @@ u8 rtw_chk_hi_queue_cmd(struct adapter *padapter)
 
      pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
      if (pdrvextra_cmd_parm == NULL) {
-             kfree((unsigned char *)ph2c);
+             kfree(ph2c);
              res = _FAIL;
              goto exit;
      }
@@ -1898,7 +1898,7 @@ u8 rtw_c2h_packet_wk_cmd(struct adapter *padapter, u8 *pbuf, u16 length)
 
      pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
      if (pdrvextra_cmd_parm == NULL) {
-             kfree((u8 *)ph2c);
+             kfree(ph2c);
              res = _FAIL;
              goto exit;
      }
@@ -1933,7 +1933,7 @@ u8 rtw_c2h_wk_cmd(struct adapter *padapter, u8 *c2h_evt)
 
      pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
      if (pdrvextra_cmd_parm == NULL) {
-             kfree((u8 *)ph2c);
+             kfree(ph2c);
              res = _FAIL;
              goto exit;
      }
--

2.7.4

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/1507380884-10906-1-git-send-email-srishtishar%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

#3 lore raw
Quoted 62 lines · Srishti Sharma
Quoted 45 lines · Julia Lawall
Quoted 41 lines · Srishti Sharma

The cast to pointer types in kfree is not needed and can be dropped. Done using the following semantic by coccinelle.

@r@
type T,P;
T* x;
@@

kfree(
-(P *)
x )

---
 drivers/staging/rtl8723bs/core/rtw_cmd.c | 58 ++++++++++++++++----------------
 1 file changed, 29 insertions(+), 29 deletions(-)
drivers/staging/rtl8723bs/core/rtw_cmd.c +2 -2
index 1843c44..e71e3ab 100644
@@ -408,7 +408,7 @@ void rtw_free_cmd_obj(struct cmd_obj *pcmd)
      }
 
      /* free cmd_obj */
-     kfree((unsigned char *)pcmd);
+     kfree(pcmd);
 }
 
 
@@ -619,7 +619,7 @@ u8 rtw_sitesurvey_cmd(struct adapter  *padapter, struct ndis_802_11_ssid *ssid,
 
      psurveyPara = rtw_zmalloc(sizeof(struct sitesurvey_parm));
      if (psurveyPara == NULL) {
-             kfree((unsigned char *) ph2c);
+             kfree(ph2c);
              return _FAIL;
      }
 
@@ -689,7 +689,7 @@ u8 rtw_setdatarate_cmd(struct adapter *padapter, u8 *rateset)
 
Quoted 16 lines

drivers/staging/rtl8723bs/core/rtw_cmd.c void rtw_getbbrfreg_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *p · line 709

Quoted 11 lines
drivers/staging/rtl8723bs/core/rtw_cmd.c +1 -1
      pbsetdataratepara = rtw_zmalloc(sizeof(struct setdatarate_parm));
      if (pbsetdataratepara == NULL) {
-             kfree((u8 *) ph2c);
+             kfree(ph2c);
              res = _FAIL;
              goto exit;
      }
@@ -707,7 +707,7 @@ void rtw_getbbrfreg_cmdrsp_callback(struct adapter *padapter,  struct cmd_obj *p
 {
      /* rtw_free_cmd_obj(pcmd); */
      kfree((unsigned char *) pcmd->parmbuf);

This case didn't get updated, probably because Coccinelle didn't have access to enough type information. Try rerunning with --all-includes or --recursive-includes. You may also need to give some include path information (-I argument).

Quoted 3 lines

I tried doing this but it is still not detecting this particular case, for the include path I gave the path of the directory which contains the header file in which struct cmd_obj is defined.

OK, just check the field type manually, and then put a note in your commit log saying that you have done that case by hand, due to Coccinelle's not having sufficient type information.

julia

Quoted 238 lines

Regards,
Srishti

Quoted 220 lines

julia

Quoted 217 lines
drivers/staging/rtl8723bs/core/rtw_cmd.c +26 -27
-     kfree((unsigned char *) pcmd);
+     kfree(pcmd);
 }
 
 u8 rtw_createbss_cmd(struct adapter  *padapter)
@@ -847,7 +847,7 @@ u8 rtw_joinbss_cmd(struct adapter  *padapter, struct wlan_network *pnetwork)
      psecnetwork = (struct wlan_bssid_ex *)&psecuritypriv->sec_bss;
      if (psecnetwork == NULL) {
              if (pcmd != NULL)
-                     kfree((unsigned char *)pcmd);
+                     kfree(pcmd);
 
              res = _FAIL;
 
@@ -955,7 +955,7 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms, bool enqueu
              cmdobj = rtw_zmalloc(sizeof(*cmdobj));
              if (cmdobj == NULL) {
                      res = _FAIL;
-                     kfree((u8 *)param);
+                     kfree(param);
                      goto exit;
              }
              init_h2fwcmd_w_parm_no_rsp(cmdobj, param, _DisConnect_CMD_);
@@ -964,7 +964,7 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms, bool enqueu
              /* no need to enqueue, do the cmd hdl directly and free cmd parameter */
              if (H2C_SUCCESS != disconnect_hdl(padapter, (u8 *)param))
                      res = _FAIL;
-             kfree((u8 *)param);
+             kfree(param);
      }
 
 exit:
@@ -990,7 +990,7 @@ u8 rtw_setopmode_cmd(struct adapter  *padapter, enum NDIS_802_11_NETWORK_INFRAST
      if (enqueue) {
              ph2c = rtw_zmalloc(sizeof(struct cmd_obj));
              if (ph2c == NULL) {
-                     kfree((u8 *)psetop);
+                     kfree(psetop);
                      res = _FAIL;
                      goto exit;
              }
@@ -999,7 +999,7 @@ u8 rtw_setopmode_cmd(struct adapter  *padapter, enum NDIS_802_11_NETWORK_INFRAST
              res = rtw_enqueue_cmd(pcmdpriv, ph2c);
      } else{
              setopmode_hdl(padapter, (u8 *)psetop);
-             kfree((u8 *)psetop);
+             kfree(psetop);
      }
 exit:
      return res;
@@ -1042,15 +1042,15 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 unicast_
      if (enqueue) {
              ph2c = rtw_zmalloc(sizeof(struct cmd_obj));
              if (ph2c == NULL) {
-                     kfree((u8 *) psetstakey_para);
+                     kfree(psetstakey_para);
                      res = _FAIL;
                      goto exit;
              }
 
              psetstakey_rsp = rtw_zmalloc(sizeof(struct set_stakey_rsp));
              if (psetstakey_rsp == NULL) {
-                     kfree((u8 *) ph2c);
-                     kfree((u8 *) psetstakey_para);
+                     kfree(ph2c);
+                     kfree(psetstakey_para);
                      res = _FAIL;
                      goto exit;
              }
@@ -1061,7 +1061,7 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 unicast_
              res = rtw_enqueue_cmd(pcmdpriv, ph2c);
      } else{
              set_stakey_hdl(padapter, (u8 *)psetstakey_para);
-             kfree((u8 *) psetstakey_para);
+             kfree(psetstakey_para);
      }
 exit:
      return res;
@@ -1091,15 +1091,15 @@ u8 rtw_clearstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 enqueu
 
              psetstakey_para = rtw_zmalloc(sizeof(struct set_stakey_parm));
              if (psetstakey_para == NULL) {
-                     kfree((u8 *) ph2c);
+                     kfree(ph2c);
                      res = _FAIL;
                      goto exit;
              }
 
              psetstakey_rsp = rtw_zmalloc(sizeof(struct set_stakey_rsp));
              if (psetstakey_rsp == NULL) {
-                     kfree((u8 *) ph2c);
-                     kfree((u8 *) psetstakey_para);
+                     kfree(ph2c);
+                     kfree(psetstakey_para);
                      res = _FAIL;
                      goto exit;
              }
@@ -1136,7 +1136,7 @@ u8 rtw_addbareq_cmd(struct adapter *padapter, u8 tid, u8 *addr)
 
      paddbareq_parm = rtw_zmalloc(sizeof(struct addBaReq_parm));
      if (paddbareq_parm == NULL) {
-             kfree((unsigned char *)ph2c);
+             kfree(ph2c);
              res = _FAIL;
              goto exit;
      }
@@ -1170,7 +1170,7 @@ u8 rtw_reset_securitypriv_cmd(struct adapter *padapter)
 
      pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
      if (pdrvextra_cmd_parm == NULL) {
-             kfree((unsigned char *)ph2c);
+             kfree(ph2c);
              res = _FAIL;
              goto exit;
      }
@@ -1205,7 +1205,7 @@ u8 rtw_free_assoc_resources_cmd(struct adapter *padapter)
 
      pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
      if (pdrvextra_cmd_parm == NULL) {
-             kfree((unsigned char *)ph2c);
+             kfree(ph2c);
              res = _FAIL;
              goto exit;
      }
@@ -1241,7 +1241,7 @@ u8 rtw_dynamic_chk_wk_cmd(struct adapter *padapter)
 
      pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
      if (pdrvextra_cmd_parm == NULL) {
-             kfree((unsigned char *)ph2c);
+             kfree(ph2c);
              res = _FAIL;
              goto exit;
      }
@@ -1294,7 +1294,7 @@ u8 rtw_set_chplan_cmd(struct adapter *padapter, u8 chplan, u8 enqueue, u8 swconf
              /* need enqueue, prepare cmd_obj and enqueue */
              pcmdobj = rtw_zmalloc(sizeof(struct cmd_obj));
              if (pcmdobj == NULL) {
-                     kfree((u8 *)setChannelPlan_param);
+                     kfree(setChannelPlan_param);
                      res = _FAIL;
                      goto exit;
              }
@@ -1306,7 +1306,7 @@ u8 rtw_set_chplan_cmd(struct adapter *padapter, u8 chplan, u8 enqueue, u8 swconf
              if (H2C_SUCCESS != set_chplan_hdl(padapter, (unsigned char *)setChannelPlan_param))
                      res = _FAIL;
 
-             kfree((u8 *)setChannelPlan_param);
+             kfree(setChannelPlan_param);
      }
 
      /* do something based on res... */
@@ -1561,7 +1561,7 @@ u8 rtw_lps_ctrl_wk_cmd(struct adapter *padapter, u8 lps_ctrl_type, u8 enqueue)
 
              pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
              if (pdrvextra_cmd_parm == NULL) {
-                     kfree((unsigned char *)ph2c);
+                     kfree(ph2c);
                      res = _FAIL;
                      goto exit;
              }
@@ -1603,7 +1603,7 @@ u8 rtw_dm_in_lps_wk_cmd(struct adapter *padapter)
 
      pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
      if (pdrvextra_cmd_parm == NULL) {
-             kfree((unsigned char *)ph2c);
+             kfree(ph2c);
              res = _FAIL;
              goto exit;
      }
@@ -1676,7 +1676,7 @@ u8 rtw_dm_ra_mask_wk_cmd(struct adapter *padapter, u8 *psta)
 
      pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
      if (pdrvextra_cmd_parm == NULL) {
-             kfree((unsigned char *)ph2c);
+             kfree(ph2c);
              res = _FAIL;
              goto exit;
      }
@@ -1727,7 +1727,7 @@ u8 rtw_ps_cmd(struct adapter *padapter)
 
      pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
      if (pdrvextra_cmd_parm == NULL) {
-             kfree((unsigned char *)ppscmd);
+             kfree(ppscmd);
              res = _FAIL;
              goto exit;
      }
@@ -1799,7 +1799,7 @@ u8 rtw_chk_hi_queue_cmd(struct adapter *padapter)
 
      pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
      if (pdrvextra_cmd_parm == NULL) {
-             kfree((unsigned char *)ph2c);
+             kfree(ph2c);
              res = _FAIL;
              goto exit;
      }
@@ -1898,7 +1898,7 @@ u8 rtw_c2h_packet_wk_cmd(struct adapter *padapter, u8 *pbuf, u16 length)
 
      pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
      if (pdrvextra_cmd_parm == NULL) {
-             kfree((u8 *)ph2c);
+             kfree(ph2c);
              res = _FAIL;
              goto exit;
      }
@@ -1933,7 +1933,7 @@ u8 rtw_c2h_wk_cmd(struct adapter *padapter, u8 *c2h_evt)
 
      pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
      if (pdrvextra_cmd_parm == NULL) {
-             kfree((u8 *)ph2c);
+             kfree(ph2c);
              res = _FAIL;
              goto exit;
      }
--

2.7.4

Quoted 7 lines
Quoted 7 lines

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/1507380884-10906-1-git-send-email-srishtishar%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/CAB3L5oxHV_buBHqmX3-Tw0UMj7ivBP3btEaRUmUa064Di%2BHUTg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

#4 lore raw
Quoted 66 lines · Julia Lawall
Quoted 62 lines · Srishti Sharma
Quoted 61 lines · Julia Lawall
Quoted 49 lines · Srishti Sharma

The cast to pointer types in kfree is not needed and can be dropped. Done using the following semantic by coccinelle.

@r@
type T,P;
T* x;
@@

kfree(
-(P *)
x )

---
 drivers/staging/rtl8723bs/core/rtw_cmd.c | 58 ++++++++++++++++----------------
 1 file changed, 29 insertions(+), 29 deletions(-)
drivers/staging/rtl8723bs/core/rtw_cmd.c +3 -3
index 1843c44..e71e3ab 100644
@@ -408,7 +408,7 @@ void rtw_free_cmd_obj(struct cmd_obj *pcmd)
      }
 
      /* free cmd_obj */
-     kfree((unsigned char *)pcmd);
+     kfree(pcmd);
 }
 
 
@@ -619,7 +619,7 @@ u8 rtw_sitesurvey_cmd(struct adapter  *padapter, struct ndis_802_11_ssid *ssid,
 
      psurveyPara = rtw_zmalloc(sizeof(struct sitesurvey_parm));
      if (psurveyPara == NULL) {
-             kfree((unsigned char *) ph2c);
+             kfree(ph2c);
              return _FAIL;
      }
 
@@ -689,7 +689,7 @@ u8 rtw_setdatarate_cmd(struct adapter *padapter, u8 *rateset)
 
      pbsetdataratepara = rtw_zmalloc(sizeof(struct setdatarate_parm));
      if (pbsetdataratepara == NULL) {
-             kfree((u8 *) ph2c);
+             kfree(ph2c);
              res = _FAIL;
              goto exit;
      }

drivers/staging/rtl8723bs/core/rtw_cmd.c void rtw_getbbrfreg_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *p · line 709

Quoted 3 lines
drivers/staging/rtl8723bs/core/rtw_cmd.c +0 -0
@@ -707,7 +707,7 @@ void rtw_getbbrfreg_cmdrsp_callback(struct adapter *padapter,  struct cmd_obj *p
 {
      /* rtw_free_cmd_obj(pcmd); */
      kfree((unsigned char *) pcmd->parmbuf);

This case didn't get updated, probably because Coccinelle didn't have access to enough type information. Try rerunning with --all-includes or --recursive-includes. You may also need to give some include path information (-I argument).

Quoted 7 lines
Quoted 3 lines

I tried doing this but it is still not detecting this particular case, for the include path I gave the path of the directory which contains the header file in which struct cmd_obj is defined.

OK, just check the field type manually, and then put a note in your commit log saying that you have done that case by hand, due to Coccinelle's not having sufficient type information.

Yes, I have checked it , it is a pointer.

Thanks,
Srishti

Quoted 241 lines

julia

Quoted 238 lines

Regards,
Srishti

Quoted 220 lines

julia

Quoted 217 lines
drivers/staging/rtl8723bs/core/rtw_cmd.c +26 -27
-     kfree((unsigned char *) pcmd);
+     kfree(pcmd);
 }
 
 u8 rtw_createbss_cmd(struct adapter  *padapter)
@@ -847,7 +847,7 @@ u8 rtw_joinbss_cmd(struct adapter  *padapter, struct wlan_network *pnetwork)
      psecnetwork = (struct wlan_bssid_ex *)&psecuritypriv->sec_bss;
      if (psecnetwork == NULL) {
              if (pcmd != NULL)
-                     kfree((unsigned char *)pcmd);
+                     kfree(pcmd);
 
              res = _FAIL;
 
@@ -955,7 +955,7 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms, bool enqueu
              cmdobj = rtw_zmalloc(sizeof(*cmdobj));
              if (cmdobj == NULL) {
                      res = _FAIL;
-                     kfree((u8 *)param);
+                     kfree(param);
                      goto exit;
              }
              init_h2fwcmd_w_parm_no_rsp(cmdobj, param, _DisConnect_CMD_);
@@ -964,7 +964,7 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms, bool enqueu
              /* no need to enqueue, do the cmd hdl directly and free cmd parameter */
              if (H2C_SUCCESS != disconnect_hdl(padapter, (u8 *)param))
                      res = _FAIL;
-             kfree((u8 *)param);
+             kfree(param);
      }
 
 exit:
@@ -990,7 +990,7 @@ u8 rtw_setopmode_cmd(struct adapter  *padapter, enum NDIS_802_11_NETWORK_INFRAST
      if (enqueue) {
              ph2c = rtw_zmalloc(sizeof(struct cmd_obj));
              if (ph2c == NULL) {
-                     kfree((u8 *)psetop);
+                     kfree(psetop);
                      res = _FAIL;
                      goto exit;
              }
@@ -999,7 +999,7 @@ u8 rtw_setopmode_cmd(struct adapter  *padapter, enum NDIS_802_11_NETWORK_INFRAST
              res = rtw_enqueue_cmd(pcmdpriv, ph2c);
      } else{
              setopmode_hdl(padapter, (u8 *)psetop);
-             kfree((u8 *)psetop);
+             kfree(psetop);
      }
 exit:
      return res;
@@ -1042,15 +1042,15 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 unicast_
      if (enqueue) {
              ph2c = rtw_zmalloc(sizeof(struct cmd_obj));
              if (ph2c == NULL) {
-                     kfree((u8 *) psetstakey_para);
+                     kfree(psetstakey_para);
                      res = _FAIL;
                      goto exit;
              }
 
              psetstakey_rsp = rtw_zmalloc(sizeof(struct set_stakey_rsp));
              if (psetstakey_rsp == NULL) {
-                     kfree((u8 *) ph2c);
-                     kfree((u8 *) psetstakey_para);
+                     kfree(ph2c);
+                     kfree(psetstakey_para);
                      res = _FAIL;
                      goto exit;
              }
@@ -1061,7 +1061,7 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 unicast_
              res = rtw_enqueue_cmd(pcmdpriv, ph2c);
      } else{
              set_stakey_hdl(padapter, (u8 *)psetstakey_para);
-             kfree((u8 *) psetstakey_para);
+             kfree(psetstakey_para);
      }
 exit:
      return res;
@@ -1091,15 +1091,15 @@ u8 rtw_clearstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 enqueu
 
              psetstakey_para = rtw_zmalloc(sizeof(struct set_stakey_parm));
              if (psetstakey_para == NULL) {
-                     kfree((u8 *) ph2c);
+                     kfree(ph2c);
                      res = _FAIL;
                      goto exit;
              }
 
              psetstakey_rsp = rtw_zmalloc(sizeof(struct set_stakey_rsp));
              if (psetstakey_rsp == NULL) {
-                     kfree((u8 *) ph2c);
-                     kfree((u8 *) psetstakey_para);
+                     kfree(ph2c);
+                     kfree(psetstakey_para);
                      res = _FAIL;
                      goto exit;
              }
@@ -1136,7 +1136,7 @@ u8 rtw_addbareq_cmd(struct adapter *padapter, u8 tid, u8 *addr)
 
      paddbareq_parm = rtw_zmalloc(sizeof(struct addBaReq_parm));
      if (paddbareq_parm == NULL) {
-             kfree((unsigned char *)ph2c);
+             kfree(ph2c);
              res = _FAIL;
              goto exit;
      }
@@ -1170,7 +1170,7 @@ u8 rtw_reset_securitypriv_cmd(struct adapter *padapter)
 
      pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
      if (pdrvextra_cmd_parm == NULL) {
-             kfree((unsigned char *)ph2c);
+             kfree(ph2c);
              res = _FAIL;
              goto exit;
      }
@@ -1205,7 +1205,7 @@ u8 rtw_free_assoc_resources_cmd(struct adapter *padapter)
 
      pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
      if (pdrvextra_cmd_parm == NULL) {
-             kfree((unsigned char *)ph2c);
+             kfree(ph2c);
              res = _FAIL;
              goto exit;
      }
@@ -1241,7 +1241,7 @@ u8 rtw_dynamic_chk_wk_cmd(struct adapter *padapter)
 
      pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
      if (pdrvextra_cmd_parm == NULL) {
-             kfree((unsigned char *)ph2c);
+             kfree(ph2c);
              res = _FAIL;
              goto exit;
      }
@@ -1294,7 +1294,7 @@ u8 rtw_set_chplan_cmd(struct adapter *padapter, u8 chplan, u8 enqueue, u8 swconf
              /* need enqueue, prepare cmd_obj and enqueue */
              pcmdobj = rtw_zmalloc(sizeof(struct cmd_obj));
              if (pcmdobj == NULL) {
-                     kfree((u8 *)setChannelPlan_param);
+                     kfree(setChannelPlan_param);
                      res = _FAIL;
                      goto exit;
              }
@@ -1306,7 +1306,7 @@ u8 rtw_set_chplan_cmd(struct adapter *padapter, u8 chplan, u8 enqueue, u8 swconf
              if (H2C_SUCCESS != set_chplan_hdl(padapter, (unsigned char *)setChannelPlan_param))
                      res = _FAIL;
 
-             kfree((u8 *)setChannelPlan_param);
+             kfree(setChannelPlan_param);
      }
 
      /* do something based on res... */
@@ -1561,7 +1561,7 @@ u8 rtw_lps_ctrl_wk_cmd(struct adapter *padapter, u8 lps_ctrl_type, u8 enqueue)
 
              pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
              if (pdrvextra_cmd_parm == NULL) {
-                     kfree((unsigned char *)ph2c);
+                     kfree(ph2c);
                      res = _FAIL;
                      goto exit;
              }
@@ -1603,7 +1603,7 @@ u8 rtw_dm_in_lps_wk_cmd(struct adapter *padapter)
 
      pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
      if (pdrvextra_cmd_parm == NULL) {
-             kfree((unsigned char *)ph2c);
+             kfree(ph2c);
              res = _FAIL;
              goto exit;
      }
@@ -1676,7 +1676,7 @@ u8 rtw_dm_ra_mask_wk_cmd(struct adapter *padapter, u8 *psta)
 
      pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
      if (pdrvextra_cmd_parm == NULL) {
-             kfree((unsigned char *)ph2c);
+             kfree(ph2c);
              res = _FAIL;
              goto exit;
      }
@@ -1727,7 +1727,7 @@ u8 rtw_ps_cmd(struct adapter *padapter)
 
      pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
      if (pdrvextra_cmd_parm == NULL) {
-             kfree((unsigned char *)ppscmd);
+             kfree(ppscmd);
              res = _FAIL;
              goto exit;
      }
@@ -1799,7 +1799,7 @@ u8 rtw_chk_hi_queue_cmd(struct adapter *padapter)
 
      pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
      if (pdrvextra_cmd_parm == NULL) {
-             kfree((unsigned char *)ph2c);
+             kfree(ph2c);
              res = _FAIL;
              goto exit;
      }
@@ -1898,7 +1898,7 @@ u8 rtw_c2h_packet_wk_cmd(struct adapter *padapter, u8 *pbuf, u16 length)
 
      pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
      if (pdrvextra_cmd_parm == NULL) {
-             kfree((u8 *)ph2c);
+             kfree(ph2c);
              res = _FAIL;
              goto exit;
      }
@@ -1933,7 +1933,7 @@ u8 rtw_c2h_wk_cmd(struct adapter *padapter, u8 *c2h_evt)
 
      pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
      if (pdrvextra_cmd_parm == NULL) {
-             kfree((u8 *)ph2c);
+             kfree(ph2c);
              res = _FAIL;
              goto exit;
      }
--

2.7.4

Quoted 7 lines
Quoted 7 lines

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/1507380884-10906-1-git-send-email-srishtishar%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/CAB3L5oxHV_buBHqmX3-Tw0UMj7ivBP3btEaRUmUa064Di%2BHUTg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.