All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: rtl8723bs: remove null test before kfree
@ 2017-04-10 13:43 Aishwarya Pant
  2017-04-10 15:54 ` Larry Finger
  0 siblings, 1 reply; 2+ messages in thread
From: Aishwarya Pant @ 2017-04-10 13:43 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Bastien Nocera, Hans de Goede, Larry Finger
  Cc: devel, linux-kernel

kfree(..) on a NULL pointer is a no-op; the null test here is redundant.
Detected by coccicheck.

Signed-off-by: Aishwarya Pant <aishpant@gmail.com>
---
 drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c |  6 ++----
 drivers/staging/rtl8723bs/hal/sdio_ops.c          |  6 ++----
 drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c |  8 ++-----
 drivers/staging/rtl8723bs/os_dep/ioctl_linux.c    | 26 ++++++-----------------
 drivers/staging/rtl8723bs/os_dep/xmit_linux.c     |  6 ++----
 5 files changed, 15 insertions(+), 37 deletions(-)

diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c
index d40ad03..910f7fa 100644
--- a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c
+++ b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c
@@ -995,8 +995,7 @@ if (1) {
 		rtw_hal_set_hwreg(padapter, HW_VAR_EFUSE_USAGE, (u8 *)&efuse_usage);
 	}
 
-	if (efuseTbl)
-		kfree(efuseTbl);
+	kfree(efuseTbl);
 }
 
 static void hal_ReadEFuse_BT(
@@ -1128,8 +1127,7 @@ static void hal_ReadEFuse_BT(
 	}
 
 exit:
-	if (efuseTbl)
-		kfree(efuseTbl);
+	kfree(efuseTbl);
 }
 
 static void Hal_ReadEFuse(
diff --git a/drivers/staging/rtl8723bs/hal/sdio_ops.c b/drivers/staging/rtl8723bs/hal/sdio_ops.c
index cf09a0a..6285b72 100644
--- a/drivers/staging/rtl8723bs/hal/sdio_ops.c
+++ b/drivers/staging/rtl8723bs/hal/sdio_ops.c
@@ -602,8 +602,7 @@ static s32 _sdio_local_read(
 	if (!err)
 		memcpy(pbuf, ptmpbuf, cnt);
 
-	if (ptmpbuf)
-		kfree(ptmpbuf);
+	kfree(ptmpbuf);
 
 	return err;
 }
@@ -646,8 +645,7 @@ s32 sdio_local_read(
 	if (!err)
 		memcpy(pbuf, ptmpbuf, cnt);
 
-	if (ptmpbuf)
-		kfree(ptmpbuf);
+	kfree(ptmpbuf);
 
 	return err;
 }
diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
index d2c6604..52aa65b 100644
--- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
+++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
@@ -1170,10 +1170,7 @@ static int cfg80211_rtw_add_key(struct wiphy *wiphy, struct net_device *ndev,
 	}
 
 addkey_end:
-	if (param)
-	{
-		kfree((u8 *)param);
-	}
+	kfree((u8 *)param);
 
 	return ret;
 
@@ -1968,8 +1965,7 @@ static int rtw_cfg80211_set_wpa_ie(struct adapter *padapter, u8 *pie, size_t iel
 		pairwise_cipher, padapter->securitypriv.ndisencryptstatus, padapter->securitypriv.ndisauthtype));
 
 exit:
-	if (buf)
-		kfree(buf);
+	kfree(buf);
 	if (ret)
 		_clr_fwstate_(&padapter->mlmepriv, WIFI_UNDER_WPS);
 	return ret;
diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
index fe3c42a..e11045f 100644
--- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
+++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
@@ -766,9 +766,7 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param,
 
 exit:
 
-	if (pwep) {
-		kfree((u8 *)pwep);
-	}
+	kfree((u8 *)pwep);
 	return ret;
 }
 
@@ -926,7 +924,7 @@ static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ie
 
 exit:
 
-	if (buf) kfree(buf);
+	kfree(buf);
 
 	return ret;
 }
@@ -2502,10 +2500,7 @@ static int rtw_wx_set_enc_ext(struct net_device *dev,
 	ret =  wpa_set_encryption(dev, param, param_len);
 
 exit:
-	if (param)
-	{
-		kfree((u8 *)param);
-	}
+	kfree((u8 *)param);
 
 	return ret;
 }
@@ -4135,11 +4130,7 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param,
 	}
 
 exit:
-
-	if (pwep)
-	{
-		kfree((u8 *)pwep);
-	}
+	kfree((u8 *)pwep);
 
 	return ret;
 
@@ -5785,12 +5776,9 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_
 	}
 
 exit:
-	if (input)
-		kfree(input);
-	if (buffer)
-		kfree(buffer);
-	if (output)
-		kfree(output);
+	kfree(input);
+	kfree(buffer);
+	kfree(output);
 
 	return err;
 }
diff --git a/drivers/staging/rtl8723bs/os_dep/xmit_linux.c b/drivers/staging/rtl8723bs/os_dep/xmit_linux.c
index 66dfec1..7696816 100644
--- a/drivers/staging/rtl8723bs/os_dep/xmit_linux.c
+++ b/drivers/staging/rtl8723bs/os_dep/xmit_linux.c
@@ -76,10 +76,8 @@ int rtw_os_xmit_resource_alloc(struct adapter *padapter, struct xmit_buf *pxmitb
 
 void rtw_os_xmit_resource_free(struct adapter *padapter, struct xmit_buf *pxmitbuf, u32 free_sz, u8 flag)
 {
-	if (free_sz > 0) {
-		if (pxmitbuf->pallocated_buf)
-			kfree(pxmitbuf->pallocated_buf);
-	}
+	if (free_sz > 0)
+		kfree(pxmitbuf->pallocated_buf);
 }
 
 #define WMM_XMIT_THRESHOLD	(NR_XMITFRAME*2/5)
-- 
2.7.4

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

* Re: [PATCH] staging: rtl8723bs: remove null test before kfree
  2017-04-10 13:43 [PATCH] staging: rtl8723bs: remove null test before kfree Aishwarya Pant
@ 2017-04-10 15:54 ` Larry Finger
  0 siblings, 0 replies; 2+ messages in thread
From: Larry Finger @ 2017-04-10 15:54 UTC (permalink / raw)
  To: Aishwarya Pant, Greg Kroah-Hartman, Bastien Nocera, Hans de Goede
  Cc: devel, linux-kernel

On 04/10/2017 08:43 AM, Aishwarya Pant wrote:
> kfree(..) on a NULL pointer is a no-op; the null test here is redundant.
> Detected by coccicheck.
>
> Signed-off-by: Aishwarya Pant <aishpant@gmail.com>

Acked-by: Larry Finger <Larry.Finger@lwfinger.net>

Thanks,

Larry

> ---
>  drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c |  6 ++----
>  drivers/staging/rtl8723bs/hal/sdio_ops.c          |  6 ++----
>  drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c |  8 ++-----
>  drivers/staging/rtl8723bs/os_dep/ioctl_linux.c    | 26 ++++++-----------------
>  drivers/staging/rtl8723bs/os_dep/xmit_linux.c     |  6 ++----
>  5 files changed, 15 insertions(+), 37 deletions(-)
>
> diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c
> index d40ad03..910f7fa 100644
> --- a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c
> +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c
> @@ -995,8 +995,7 @@ if (1) {
>  		rtw_hal_set_hwreg(padapter, HW_VAR_EFUSE_USAGE, (u8 *)&efuse_usage);
>  	}
>
> -	if (efuseTbl)
> -		kfree(efuseTbl);
> +	kfree(efuseTbl);
>  }
>
>  static void hal_ReadEFuse_BT(
> @@ -1128,8 +1127,7 @@ static void hal_ReadEFuse_BT(
>  	}
>
>  exit:
> -	if (efuseTbl)
> -		kfree(efuseTbl);
> +	kfree(efuseTbl);
>  }
>
>  static void Hal_ReadEFuse(
> diff --git a/drivers/staging/rtl8723bs/hal/sdio_ops.c b/drivers/staging/rtl8723bs/hal/sdio_ops.c
> index cf09a0a..6285b72 100644
> --- a/drivers/staging/rtl8723bs/hal/sdio_ops.c
> +++ b/drivers/staging/rtl8723bs/hal/sdio_ops.c
> @@ -602,8 +602,7 @@ static s32 _sdio_local_read(
>  	if (!err)
>  		memcpy(pbuf, ptmpbuf, cnt);
>
> -	if (ptmpbuf)
> -		kfree(ptmpbuf);
> +	kfree(ptmpbuf);
>
>  	return err;
>  }
> @@ -646,8 +645,7 @@ s32 sdio_local_read(
>  	if (!err)
>  		memcpy(pbuf, ptmpbuf, cnt);
>
> -	if (ptmpbuf)
> -		kfree(ptmpbuf);
> +	kfree(ptmpbuf);
>
>  	return err;
>  }
> diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
> index d2c6604..52aa65b 100644
> --- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
> +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
> @@ -1170,10 +1170,7 @@ static int cfg80211_rtw_add_key(struct wiphy *wiphy, struct net_device *ndev,
>  	}
>
>  addkey_end:
> -	if (param)
> -	{
> -		kfree((u8 *)param);
> -	}
> +	kfree((u8 *)param);
>
>  	return ret;
>
> @@ -1968,8 +1965,7 @@ static int rtw_cfg80211_set_wpa_ie(struct adapter *padapter, u8 *pie, size_t iel
>  		pairwise_cipher, padapter->securitypriv.ndisencryptstatus, padapter->securitypriv.ndisauthtype));
>
>  exit:
> -	if (buf)
> -		kfree(buf);
> +	kfree(buf);
>  	if (ret)
>  		_clr_fwstate_(&padapter->mlmepriv, WIFI_UNDER_WPS);
>  	return ret;
> diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
> index fe3c42a..e11045f 100644
> --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
> +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
> @@ -766,9 +766,7 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param,
>
>  exit:
>
> -	if (pwep) {
> -		kfree((u8 *)pwep);
> -	}
> +	kfree((u8 *)pwep);
>  	return ret;
>  }
>
> @@ -926,7 +924,7 @@ static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ie
>
>  exit:
>
> -	if (buf) kfree(buf);
> +	kfree(buf);
>
>  	return ret;
>  }
> @@ -2502,10 +2500,7 @@ static int rtw_wx_set_enc_ext(struct net_device *dev,
>  	ret =  wpa_set_encryption(dev, param, param_len);
>
>  exit:
> -	if (param)
> -	{
> -		kfree((u8 *)param);
> -	}
> +	kfree((u8 *)param);
>
>  	return ret;
>  }
> @@ -4135,11 +4130,7 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param,
>  	}
>
>  exit:
> -
> -	if (pwep)
> -	{
> -		kfree((u8 *)pwep);
> -	}
> +	kfree((u8 *)pwep);
>
>  	return ret;
>
> @@ -5785,12 +5776,9 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_
>  	}
>
>  exit:
> -	if (input)
> -		kfree(input);
> -	if (buffer)
> -		kfree(buffer);
> -	if (output)
> -		kfree(output);
> +	kfree(input);
> +	kfree(buffer);
> +	kfree(output);
>
>  	return err;
>  }
> diff --git a/drivers/staging/rtl8723bs/os_dep/xmit_linux.c b/drivers/staging/rtl8723bs/os_dep/xmit_linux.c
> index 66dfec1..7696816 100644
> --- a/drivers/staging/rtl8723bs/os_dep/xmit_linux.c
> +++ b/drivers/staging/rtl8723bs/os_dep/xmit_linux.c
> @@ -76,10 +76,8 @@ int rtw_os_xmit_resource_alloc(struct adapter *padapter, struct xmit_buf *pxmitb
>
>  void rtw_os_xmit_resource_free(struct adapter *padapter, struct xmit_buf *pxmitbuf, u32 free_sz, u8 flag)
>  {
> -	if (free_sz > 0) {
> -		if (pxmitbuf->pallocated_buf)
> -			kfree(pxmitbuf->pallocated_buf);
> -	}
> +	if (free_sz > 0)
> +		kfree(pxmitbuf->pallocated_buf);
>  }
>
>  #define WMM_XMIT_THRESHOLD	(NR_XMITFRAME*2/5)
>

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

end of thread, other threads:[~2017-04-10 15:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-10 13:43 [PATCH] staging: rtl8723bs: remove null test before kfree Aishwarya Pant
2017-04-10 15:54 ` Larry Finger

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.