diff mbox

nfsd4: fix memory leak in nfsd4_encode_fattr()

Message ID 1394427127-9985-1-git-send-email-zheng.z.yan@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Yan, Zheng March 10, 2014, 4:52 a.m. UTC
fh_put() does not free the temporary file handle.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
---
 fs/nfsd/nfs4xdr.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Christoph Hellwig March 10, 2014, 8:04 a.m. UTC | #1
On Mon, Mar 10, 2014 at 12:52:07PM +0800, Yan, Zheng wrote:
> fh_put() does not free the temporary file handle.

Btw, it seems like the code to generate the file handle if it's missing
should be moved out of nfsd4_encode_fattr and into
nfsd4_encode_dirent_fattr or a small helper just called from there so that:

 a) the code flow is more obvious
 b) the calling conventions for nfsd4_encode_fattr are sensible
 c) nfsd4_encode_fattr shrinks at least a tiny bit
 d) the required cleanup becomes more obvious by being paired with the
    allocation and initialization of the FH.

Just curious: which client asks for the FH or FSID in READDIRPLUS?
--
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
Yan, Zheng March 10, 2014, 8:29 a.m. UTC | #2
On 03/10/2014 04:04 PM, Christoph Hellwig wrote:
> On Mon, Mar 10, 2014 at 12:52:07PM +0800, Yan, Zheng wrote:
>> fh_put() does not free the temporary file handle.
> 
> Btw, it seems like the code to generate the file handle if it's missing
> should be moved out of nfsd4_encode_fattr and into
> nfsd4_encode_dirent_fattr or a small helper just called from there so that:
> 
>  a) the code flow is more obvious
>  b) the calling conventions for nfsd4_encode_fattr are sensible
>  c) nfsd4_encode_fattr shrinks at least a tiny bit
>  d) the required cleanup becomes more obvious by being paired with the
>     allocation and initialization of the FH.
> 
> Just curious: which client asks for the FH or FSID in READDIRPLUS?
> 

Both nfs server and client are complied from 3.14-rc5 kernel. The exported
FS is Ceph.

Regards
Yan, Zheng
 
--
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
J. Bruce Fields March 31, 2014, 9:11 p.m. UTC | #3
On Mon, Mar 10, 2014 at 12:52:07PM +0800, Yan, Zheng wrote:
> fh_put() does not free the temporary file handle.

Applying, sorry for the delay.--b.

> 
> Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
> ---
>  fs/nfsd/nfs4xdr.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
> index 63f2395..8de4c9d 100644
> --- a/fs/nfsd/nfs4xdr.c
> +++ b/fs/nfsd/nfs4xdr.c
> @@ -2499,8 +2499,10 @@ out:
>  		security_release_secctx(context, contextlen);
>  #endif /* CONFIG_NFSD_V4_SECURITY_LABEL */
>  	kfree(acl);
> -	if (tempfh)
> +	if (tempfh) {
>  		fh_put(tempfh);
> +		kfree(tempfh);
> +	}
>  	return status;
>  out_nfserr:
>  	status = nfserrno(err);
> -- 
> 1.8.5.3
> 
--
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

diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index 63f2395..8de4c9d 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -2499,8 +2499,10 @@  out:
 		security_release_secctx(context, contextlen);
 #endif /* CONFIG_NFSD_V4_SECURITY_LABEL */
 	kfree(acl);
-	if (tempfh)
+	if (tempfh) {
 		fh_put(tempfh);
+		kfree(tempfh);
+	}
 	return status;
 out_nfserr:
 	status = nfserrno(err);