All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Staging: rtl8723bs: core: rtw_mlme_ext.c: Remove typecast in kfree
@ 2019-04-01  2:31 Madhumitha Prabakaran
  2019-04-01  6:15 ` [Outreachy kernel] " Julia Lawall
  0 siblings, 1 reply; 3+ messages in thread
From: Madhumitha Prabakaran @ 2019-04-01  2:31 UTC (permalink / raw)
  To: gregkh, outreachy-kernel; +Cc: Madhumitha Prabakaran

Remove typecast in kfree, as the function will free any memory
that is allocated with kmalloc.

Signed-off-by: Madhumitha Prabakaran <madhumithabiw@gmail.com>
---
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 22 +++++++++----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
index d97c1e6d5c01..430758f298af 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
@@ -816,7 +816,7 @@ unsigned int OnBeacon(struct adapter *padapter, union recv_frame *precv_frame)
 					update_network(&(pmlmepriv->cur_network.network), pbss, padapter, true);
 					rtw_get_bcn_info(&(pmlmepriv->cur_network));
 				}
-				kfree((u8 *)pbss);
+				kfree(pbss);
 			}
 
 			/* check the vendor of the assoc AP */
@@ -5043,7 +5043,7 @@ void report_survey_event(struct adapter *padapter, union recv_frame *precv_frame
 	cmdsz = (sizeof(struct survey_event) + sizeof(struct C2HEvent_Header));
 	pevtcmd = rtw_zmalloc(cmdsz);
 	if (pevtcmd == NULL) {
-		kfree((u8 *)pcmd_obj);
+		kfree(pcmd_obj);
 		return;
 	}
 
@@ -5064,8 +5064,8 @@ void report_survey_event(struct adapter *padapter, union recv_frame *precv_frame
 	psurvey_evt = (struct survey_event *)(pevtcmd + sizeof(struct C2HEvent_Header));
 
 	if (collect_bss_info(padapter, precv_frame, (struct wlan_bssid_ex *)&psurvey_evt->bss) == _FAIL) {
-		kfree((u8 *)pcmd_obj);
-		kfree((u8 *)pevtcmd);
+		kfree(pcmd_obj);
+		kfree(pevtcmd);
 		return;
 	}
 
@@ -5096,7 +5096,7 @@ void report_surveydone_event(struct adapter *padapter)
 	cmdsz = (sizeof(struct surveydone_event) + sizeof(struct C2HEvent_Header));
 	pevtcmd = rtw_zmalloc(cmdsz);
 	if (pevtcmd == NULL) {
-		kfree((u8 *)pcmd_obj);
+		kfree(pcmd_obj);
 		return;
 	}
 
@@ -5143,7 +5143,7 @@ void report_join_res(struct adapter *padapter, int res)
 	cmdsz = (sizeof(struct joinbss_event) + sizeof(struct C2HEvent_Header));
 	pevtcmd = rtw_zmalloc(cmdsz);
 	if (pevtcmd == NULL) {
-		kfree((u8 *)pcmd_obj);
+		kfree(pcmd_obj);
 		return;
 	}
 
@@ -5194,7 +5194,7 @@ void report_wmm_edca_update(struct adapter *padapter)
 	cmdsz = (sizeof(struct wmm_event) + sizeof(struct C2HEvent_Header));
 	pevtcmd = rtw_zmalloc(cmdsz);
 	if (pevtcmd == NULL) {
-		kfree((u8 *)pcmd_obj);
+		kfree((pcmd_obj);
 		return;
 	}
 
@@ -5241,7 +5241,7 @@ void report_del_sta_event(struct adapter *padapter, unsigned char *MacAddr, unsi
 	cmdsz = (sizeof(struct stadel_event) + sizeof(struct C2HEvent_Header));
 	pevtcmd = rtw_zmalloc(cmdsz);
 	if (pevtcmd == NULL) {
-		kfree((u8 *)pcmd_obj);
+		kfree(pcmd_obj);
 		return;
 	}
 
@@ -5296,7 +5296,7 @@ void report_add_sta_event(struct adapter *padapter, unsigned char *MacAddr, int
 	cmdsz = (sizeof(struct stassoc_event) + sizeof(struct C2HEvent_Header));
 	pevtcmd = rtw_zmalloc(cmdsz);
 	if (pevtcmd == NULL) {
-		kfree((u8 *)pcmd_obj);
+		kfree(pcmd_obj);
 		return;
 	}
 
@@ -5822,7 +5822,7 @@ void survey_timer_hdl(struct timer_list *t)
 
 		psurveyPara = rtw_zmalloc(sizeof(struct sitesurvey_parm));
 		if (psurveyPara == NULL) {
-			kfree((unsigned char *)ph2c);
+			kfree(ph2c);
 			goto exit_survey_timer_hdl;
 		}
 
@@ -6589,7 +6589,7 @@ u8 set_tx_beacon_cmd(struct adapter *padapter)
 
 	ptxBeacon_parm = rtw_zmalloc(sizeof(struct Tx_Beacon_param));
 	if (ptxBeacon_parm == NULL) {
-		kfree((unsigned char *)ph2c);
+		kfree(ph2c);
 		res = _FAIL;
 		goto exit;
 	}
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Outreachy kernel] [PATCH] Staging: rtl8723bs: core: rtw_mlme_ext.c: Remove typecast in kfree
  2019-04-01  2:31 [PATCH] Staging: rtl8723bs: core: rtw_mlme_ext.c: Remove typecast in kfree Madhumitha Prabakaran
@ 2019-04-01  6:15 ` Julia Lawall
  2019-04-01 18:06   ` Madhumthia Prabakaran
  0 siblings, 1 reply; 3+ messages in thread
From: Julia Lawall @ 2019-04-01  6:15 UTC (permalink / raw)
  To: Madhumitha Prabakaran; +Cc: gregkh, outreachy-kernel



On Sun, 31 Mar 2019, Madhumitha Prabakaran wrote:

> Remove typecast in kfree, as the function will free any memory
> that is allocated with kmalloc.

The change is fine, but the explanation is not really correct.  The
parameter type of kfree is void *, and C is happy to cast any pointer type
to void *.

julia

>
> Signed-off-by: Madhumitha Prabakaran <madhumithabiw@gmail.com>
> ---
>  drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 22 +++++++++----------
>  1 file changed, 11 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
> index d97c1e6d5c01..430758f298af 100644
> --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
> +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
> @@ -816,7 +816,7 @@ unsigned int OnBeacon(struct adapter *padapter, union recv_frame *precv_frame)
>  					update_network(&(pmlmepriv->cur_network.network), pbss, padapter, true);
>  					rtw_get_bcn_info(&(pmlmepriv->cur_network));
>  				}
> -				kfree((u8 *)pbss);
> +				kfree(pbss);
>  			}
>
>  			/* check the vendor of the assoc AP */
> @@ -5043,7 +5043,7 @@ void report_survey_event(struct adapter *padapter, union recv_frame *precv_frame
>  	cmdsz = (sizeof(struct survey_event) + sizeof(struct C2HEvent_Header));
>  	pevtcmd = rtw_zmalloc(cmdsz);
>  	if (pevtcmd == NULL) {
> -		kfree((u8 *)pcmd_obj);
> +		kfree(pcmd_obj);
>  		return;
>  	}
>
> @@ -5064,8 +5064,8 @@ void report_survey_event(struct adapter *padapter, union recv_frame *precv_frame
>  	psurvey_evt = (struct survey_event *)(pevtcmd + sizeof(struct C2HEvent_Header));
>
>  	if (collect_bss_info(padapter, precv_frame, (struct wlan_bssid_ex *)&psurvey_evt->bss) == _FAIL) {
> -		kfree((u8 *)pcmd_obj);
> -		kfree((u8 *)pevtcmd);
> +		kfree(pcmd_obj);
> +		kfree(pevtcmd);
>  		return;
>  	}
>
> @@ -5096,7 +5096,7 @@ void report_surveydone_event(struct adapter *padapter)
>  	cmdsz = (sizeof(struct surveydone_event) + sizeof(struct C2HEvent_Header));
>  	pevtcmd = rtw_zmalloc(cmdsz);
>  	if (pevtcmd == NULL) {
> -		kfree((u8 *)pcmd_obj);
> +		kfree(pcmd_obj);
>  		return;
>  	}
>
> @@ -5143,7 +5143,7 @@ void report_join_res(struct adapter *padapter, int res)
>  	cmdsz = (sizeof(struct joinbss_event) + sizeof(struct C2HEvent_Header));
>  	pevtcmd = rtw_zmalloc(cmdsz);
>  	if (pevtcmd == NULL) {
> -		kfree((u8 *)pcmd_obj);
> +		kfree(pcmd_obj);
>  		return;
>  	}
>
> @@ -5194,7 +5194,7 @@ void report_wmm_edca_update(struct adapter *padapter)
>  	cmdsz = (sizeof(struct wmm_event) + sizeof(struct C2HEvent_Header));
>  	pevtcmd = rtw_zmalloc(cmdsz);
>  	if (pevtcmd == NULL) {
> -		kfree((u8 *)pcmd_obj);
> +		kfree((pcmd_obj);
>  		return;
>  	}
>
> @@ -5241,7 +5241,7 @@ void report_del_sta_event(struct adapter *padapter, unsigned char *MacAddr, unsi
>  	cmdsz = (sizeof(struct stadel_event) + sizeof(struct C2HEvent_Header));
>  	pevtcmd = rtw_zmalloc(cmdsz);
>  	if (pevtcmd == NULL) {
> -		kfree((u8 *)pcmd_obj);
> +		kfree(pcmd_obj);
>  		return;
>  	}
>
> @@ -5296,7 +5296,7 @@ void report_add_sta_event(struct adapter *padapter, unsigned char *MacAddr, int
>  	cmdsz = (sizeof(struct stassoc_event) + sizeof(struct C2HEvent_Header));
>  	pevtcmd = rtw_zmalloc(cmdsz);
>  	if (pevtcmd == NULL) {
> -		kfree((u8 *)pcmd_obj);
> +		kfree(pcmd_obj);
>  		return;
>  	}
>
> @@ -5822,7 +5822,7 @@ void survey_timer_hdl(struct timer_list *t)
>
>  		psurveyPara = rtw_zmalloc(sizeof(struct sitesurvey_parm));
>  		if (psurveyPara == NULL) {
> -			kfree((unsigned char *)ph2c);
> +			kfree(ph2c);
>  			goto exit_survey_timer_hdl;
>  		}
>
> @@ -6589,7 +6589,7 @@ u8 set_tx_beacon_cmd(struct adapter *padapter)
>
>  	ptxBeacon_parm = rtw_zmalloc(sizeof(struct Tx_Beacon_param));
>  	if (ptxBeacon_parm == NULL) {
> -		kfree((unsigned char *)ph2c);
> +		kfree(ph2c);
>  		res = _FAIL;
>  		goto exit;
>  	}
> --
> 2.17.1
>
> --
> 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 outreachy-kernel+unsubscribe@googlegroups.com.
> To post to this group, send email to outreachy-kernel@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20190401023154.3644-1-madhumithabiw%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Outreachy kernel] [PATCH] Staging: rtl8723bs: core: rtw_mlme_ext.c: Remove typecast in kfree
  2019-04-01  6:15 ` [Outreachy kernel] " Julia Lawall
@ 2019-04-01 18:06   ` Madhumthia Prabakaran
  0 siblings, 0 replies; 3+ messages in thread
From: Madhumthia Prabakaran @ 2019-04-01 18:06 UTC (permalink / raw)
  To: Julia Lawall, outreachy-kernel

On Mon, Apr 01, 2019 at 08:15:21AM +0200, Julia Lawall wrote:
> 
> 
> On Sun, 31 Mar 2019, Madhumitha Prabakaran wrote:
> 
> > Remove typecast in kfree, as the function will free any memory
> > that is allocated with kmalloc.
> 
> The change is fine, but the explanation is not really correct.  The
> parameter type of kfree is void *, and C is happy to cast any pointer type
> to void *.

Thanks

> 
> julia
> 
> >
> > Signed-off-by: Madhumitha Prabakaran <madhumithabiw@gmail.com>
> > ---
> >  drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 22 +++++++++----------
> >  1 file changed, 11 insertions(+), 11 deletions(-)
> >
> > diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
> > index d97c1e6d5c01..430758f298af 100644
> > --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
> > +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
> > @@ -816,7 +816,7 @@ unsigned int OnBeacon(struct adapter *padapter, union recv_frame *precv_frame)
> >  					update_network(&(pmlmepriv->cur_network.network), pbss, padapter, true);
> >  					rtw_get_bcn_info(&(pmlmepriv->cur_network));
> >  				}
> > -				kfree((u8 *)pbss);
> > +				kfree(pbss);
> >  			}
> >
> >  			/* check the vendor of the assoc AP */
> > @@ -5043,7 +5043,7 @@ void report_survey_event(struct adapter *padapter, union recv_frame *precv_frame
> >  	cmdsz = (sizeof(struct survey_event) + sizeof(struct C2HEvent_Header));
> >  	pevtcmd = rtw_zmalloc(cmdsz);
> >  	if (pevtcmd == NULL) {
> > -		kfree((u8 *)pcmd_obj);
> > +		kfree(pcmd_obj);
> >  		return;
> >  	}
> >
> > @@ -5064,8 +5064,8 @@ void report_survey_event(struct adapter *padapter, union recv_frame *precv_frame
> >  	psurvey_evt = (struct survey_event *)(pevtcmd + sizeof(struct C2HEvent_Header));
> >
> >  	if (collect_bss_info(padapter, precv_frame, (struct wlan_bssid_ex *)&psurvey_evt->bss) == _FAIL) {
> > -		kfree((u8 *)pcmd_obj);
> > -		kfree((u8 *)pevtcmd);
> > +		kfree(pcmd_obj);
> > +		kfree(pevtcmd);
> >  		return;
> >  	}
> >
> > @@ -5096,7 +5096,7 @@ void report_surveydone_event(struct adapter *padapter)
> >  	cmdsz = (sizeof(struct surveydone_event) + sizeof(struct C2HEvent_Header));
> >  	pevtcmd = rtw_zmalloc(cmdsz);
> >  	if (pevtcmd == NULL) {
> > -		kfree((u8 *)pcmd_obj);
> > +		kfree(pcmd_obj);
> >  		return;
> >  	}
> >
> > @@ -5143,7 +5143,7 @@ void report_join_res(struct adapter *padapter, int res)
> >  	cmdsz = (sizeof(struct joinbss_event) + sizeof(struct C2HEvent_Header));
> >  	pevtcmd = rtw_zmalloc(cmdsz);
> >  	if (pevtcmd == NULL) {
> > -		kfree((u8 *)pcmd_obj);
> > +		kfree(pcmd_obj);
> >  		return;
> >  	}
> >
> > @@ -5194,7 +5194,7 @@ void report_wmm_edca_update(struct adapter *padapter)
> >  	cmdsz = (sizeof(struct wmm_event) + sizeof(struct C2HEvent_Header));
> >  	pevtcmd = rtw_zmalloc(cmdsz);
> >  	if (pevtcmd == NULL) {
> > -		kfree((u8 *)pcmd_obj);
> > +		kfree((pcmd_obj);
> >  		return;
> >  	}
> >
> > @@ -5241,7 +5241,7 @@ void report_del_sta_event(struct adapter *padapter, unsigned char *MacAddr, unsi
> >  	cmdsz = (sizeof(struct stadel_event) + sizeof(struct C2HEvent_Header));
> >  	pevtcmd = rtw_zmalloc(cmdsz);
> >  	if (pevtcmd == NULL) {
> > -		kfree((u8 *)pcmd_obj);
> > +		kfree(pcmd_obj);
> >  		return;
> >  	}
> >
> > @@ -5296,7 +5296,7 @@ void report_add_sta_event(struct adapter *padapter, unsigned char *MacAddr, int
> >  	cmdsz = (sizeof(struct stassoc_event) + sizeof(struct C2HEvent_Header));
> >  	pevtcmd = rtw_zmalloc(cmdsz);
> >  	if (pevtcmd == NULL) {
> > -		kfree((u8 *)pcmd_obj);
> > +		kfree(pcmd_obj);
> >  		return;
> >  	}
> >
> > @@ -5822,7 +5822,7 @@ void survey_timer_hdl(struct timer_list *t)
> >
> >  		psurveyPara = rtw_zmalloc(sizeof(struct sitesurvey_parm));
> >  		if (psurveyPara == NULL) {
> > -			kfree((unsigned char *)ph2c);
> > +			kfree(ph2c);
> >  			goto exit_survey_timer_hdl;
> >  		}
> >
> > @@ -6589,7 +6589,7 @@ u8 set_tx_beacon_cmd(struct adapter *padapter)
> >
> >  	ptxBeacon_parm = rtw_zmalloc(sizeof(struct Tx_Beacon_param));
> >  	if (ptxBeacon_parm == NULL) {
> > -		kfree((unsigned char *)ph2c);
> > +		kfree(ph2c);
> >  		res = _FAIL;
> >  		goto exit;
> >  	}
> > --
> > 2.17.1
> >
> > --
> > 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 outreachy-kernel+unsubscribe@googlegroups.com.
> > To post to this group, send email to outreachy-kernel@googlegroups.com.
> > To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20190401023154.3644-1-madhumithabiw%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 outreachy-kernel+unsubscribe@googlegroups.com.
> To post to this group, send email to outreachy-kernel@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/alpine.DEB.2.21.1904010814380.2664%40hadrien.
> For more options, visit https://groups.google.com/d/optout.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-04-01 18:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-01  2:31 [PATCH] Staging: rtl8723bs: core: rtw_mlme_ext.c: Remove typecast in kfree Madhumitha Prabakaran
2019-04-01  6:15 ` [Outreachy kernel] " Julia Lawall
2019-04-01 18:06   ` Madhumthia Prabakaran

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.