diff options
author | J. Bruce Fields <bfields@citi.umich.edu> | 2009-09-04 14:40:36 -0400 |
---|---|---|
committer | J. Bruce Fields <bfields@citi.umich.edu> | 2009-09-04 15:48:00 -0400 |
commit | aed100fafb90aaabe8fb31e58af9dc7e68696507 (patch) | |
tree | 2567f2aa9f0bac26910e6d2910fbdd044a5ab8e2 | |
parent | 8177e6d6dfb9cd03d9bdeb647c32161f8f58f686 (diff) |
nfsd: fix leak on error in nfsv3 readdir
Note the !dchild->d_inode case can leak the filehandle.
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
-rw-r--r-- | fs/nfsd/nfs3xdr.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c index f16184a39941..edf926e1062f 100644 --- a/fs/nfsd/nfs3xdr.c +++ b/fs/nfsd/nfs3xdr.c | |||
@@ -825,7 +825,6 @@ compose_entry_fh(struct nfsd3_readdirres *cd, struct svc_fh *fhp, | |||
825 | dparent = cd->fh.fh_dentry; | 825 | dparent = cd->fh.fh_dentry; |
826 | exp = cd->fh.fh_export; | 826 | exp = cd->fh.fh_export; |
827 | 827 | ||
828 | fh_init(fhp, NFS3_FHSIZE); | ||
829 | if (isdotent(name, namlen)) { | 828 | if (isdotent(name, namlen)) { |
830 | if (namlen == 2) { | 829 | if (namlen == 2) { |
831 | dchild = dget_parent(dparent); | 830 | dchild = dget_parent(dparent); |
@@ -859,15 +858,17 @@ __be32 *encode_entryplus_baggage(struct nfsd3_readdirres *cd, __be32 *p, const c | |||
859 | struct svc_fh fh; | 858 | struct svc_fh fh; |
860 | int err; | 859 | int err; |
861 | 860 | ||
861 | fh_init(&fh, NFS3_FHSIZE); | ||
862 | err = compose_entry_fh(cd, &fh, name, namlen); | 862 | err = compose_entry_fh(cd, &fh, name, namlen); |
863 | if (err) { | 863 | if (err) { |
864 | *p++ = 0; | 864 | *p++ = 0; |
865 | *p++ = 0; | 865 | *p++ = 0; |
866 | return p; | 866 | goto out; |
867 | } | 867 | } |
868 | p = encode_post_op_attr(cd->rqstp, p, &fh); | 868 | p = encode_post_op_attr(cd->rqstp, p, &fh); |
869 | *p++ = xdr_one; /* yes, a file handle follows */ | 869 | *p++ = xdr_one; /* yes, a file handle follows */ |
870 | p = encode_fh(p, &fh); | 870 | p = encode_fh(p, &fh); |
871 | out: | ||
871 | fh_put(&fh); | 872 | fh_put(&fh); |
872 | return p; | 873 | return p; |
873 | } | 874 | } |