NFS: simplify check for freeing cn_resp
Subsystems (2)
PATCH 1/1 NFS: simplify check for freeing cn_resp
From: Tom Rix <[email protected]>
nfs42_files_from_same_server() is called to check if freeing cn_resp is required. Instead of calling a function, check the pointer.
--- fs/nfs/nfs4file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfs/nfs4file.c +1 -1
@@ -180,7 +180,7 @@ static ssize_t __nfs4_copy_file_range(struct file *file_in, loff_t pos_in, ret =nfs42_proc_copy (file_in, pos_in, file_out, pos_out, count, nss, cnrs, sync); out: -if (!nfs42_files_from_same_server (file_in, file_out)) +if (cn_resp)kfree (cn_resp);if (ret == -EAGAIN ) goto retry;
Signature · 1 line
2.26.3
Hi Tom,
Quoted 20 lines · On Sun, 2022-01-16 at 06:43 -0800, [email protected] wrote:
From: Tom Rix <[email protected]>
nfs42_files_from_same_server()is called to check if freeingcn_respis required. Instead of calling a function, check the pointer.Signed-off-by Tom Rix <[email protected]>---
fs/nfs/nfs4file.c | 2 +-1 file changed, 1 insertion(+), 1 deletion(-)fs/nfs/nfs4file.c +0
-0@@ -180,7 +180,7 @@ static ssize_t __nfs4_copy_file_range(struct file *file_in, loff_t pos_in, ret = nfs42_proc_copy(file_in, pos_in, file_out, pos_out, count, nss, cnrs, sync);
Quoted 4 lines
out:
- if (!nfs42_files_from_same_server(file_in,file_out)) + if (cn_resp)
kfree(cn_resp);
The kernel convention in these circumstances is to just skip the NULL pointer check, since kfree() does that anyway.
Quoted 2 lines
if (ret ==
-EAGAIN)
goto retry;
Signature · 3 lines
Trond Myklebust Linux NFS client maintainer, Hammerspace [email protected]
Quoted 14 lines · Trond Myklebust
Hi Tom,
Quoted 11 lines · On Sun, 2022-01-16 at 06:43 -0800, [email protected] wrote:
From: Tom Rix <[email protected]>
nfs42_files_from_same_server()is called to check if freeingcn_respis required. Instead of calling a function, check the pointer.Signed-off-by Tom Rix <[email protected]>--- fs/nfs/nfs4file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 15 lines
fs/nfs/nfs4file.c static ssize_t __nfs4_copy_file_range(struct file · line 186
Quoted 13 lines
fs/nfs/nfs4file.c +1
-1@@ -180,7 +180,7 @@ static ssize_t __nfs4_copy_file_range(struct file *file_in, loff_t pos_in, ret = nfs42_proc_copy(file_in, pos_in, file_out, pos_out, count, nss, cnrs, sync); out: - if (!nfs42_files_from_same_server(file_in, file_out)) + if (cn_resp) kfree(cn_resp);The kernel convention in these circumstances is to just skip the NULL pointer check, since
kfree()does that anyway.
Yes. I'll respin.
Tom
Quoted 3 lines
Quoted 3 lines
if (ret ==
-EAGAIN)
goto retry;