diff mbox

nfsd4: fix ifnullfree.cocci warnings

Message ID 20170217193521.GA62045@lkp-sb04.lkp.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

kernel test robot Feb. 17, 2017, 7:35 p.m. UTC
fs/nfs/nfs4proc.c:5135:2-7: WARNING: NULL check before freeing functions like kfree, debugfs_remove, debugfs_remove_recursive or usb_free_urb is not needed. Maybe consider reorganizing relevant code to avoid passing NULL values.

 NULL check before some freeing functions is not needed.

 Based on checkpatch warning
 "kfree(NULL) is safe this check is probably not required"
 and kfreeaddr.cocci by Julia Lawall.

Generated by: scripts/coccinelle/free/ifnullfree.cocci

CC: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
---

 nfs4proc.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

J. Bruce Fields Feb. 17, 2017, 7:34 p.m. UTC | #1
Fixed locally.--b.

On Sat, Feb 18, 2017 at 03:35:21AM +0800, kbuild test robot wrote:
> fs/nfs/nfs4proc.c:5135:2-7: WARNING: NULL check before freeing functions like kfree, debugfs_remove, debugfs_remove_recursive or usb_free_urb is not needed. Maybe consider reorganizing relevant code to avoid passing NULL values.
> 
>  NULL check before some freeing functions is not needed.
> 
>  Based on checkpatch warning
>  "kfree(NULL) is safe this check is probably not required"
>  and kfreeaddr.cocci by Julia Lawall.
> 
> Generated by: scripts/coccinelle/free/ifnullfree.cocci
> 
> CC: J. Bruce Fields <bfields@redhat.com>
> Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
> ---
> 
>  nfs4proc.c |    3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> --- a/fs/nfs/nfs4proc.c
> +++ b/fs/nfs/nfs4proc.c
> @@ -5131,8 +5131,7 @@ static ssize_t __nfs4_get_acl_uncached(s
>  	if (buf && ret > buflen)
>  		ret = -ERANGE;
>  out:
> -	if (priv_buf)
> -		kfree(priv_buf);
> +	kfree(priv_buf);
>  	return ret;
>  }
>  
> --
> To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -5131,8 +5131,7 @@  static ssize_t __nfs4_get_acl_uncached(s
 	if (buf && ret > buflen)
 		ret = -ERANGE;
 out:
-	if (priv_buf)
-		kfree(priv_buf);
+	kfree(priv_buf);
 	return ret;
 }