提交 aed100fa 编写于 作者: J J. Bruce Fields

nfsd: fix leak on error in nfsv3 readdir

Note the !dchild->d_inode case can leak the filehandle.
Signed-off-by: NJ. Bruce Fields <bfields@citi.umich.edu>
上级 8177e6d6
...@@ -825,7 +825,6 @@ compose_entry_fh(struct nfsd3_readdirres *cd, struct svc_fh *fhp, ...@@ -825,7 +825,6 @@ compose_entry_fh(struct nfsd3_readdirres *cd, struct svc_fh *fhp,
dparent = cd->fh.fh_dentry; dparent = cd->fh.fh_dentry;
exp = cd->fh.fh_export; exp = cd->fh.fh_export;
fh_init(fhp, NFS3_FHSIZE);
if (isdotent(name, namlen)) { if (isdotent(name, namlen)) {
if (namlen == 2) { if (namlen == 2) {
dchild = dget_parent(dparent); dchild = dget_parent(dparent);
...@@ -859,15 +858,17 @@ __be32 *encode_entryplus_baggage(struct nfsd3_readdirres *cd, __be32 *p, const c ...@@ -859,15 +858,17 @@ __be32 *encode_entryplus_baggage(struct nfsd3_readdirres *cd, __be32 *p, const c
struct svc_fh fh; struct svc_fh fh;
int err; int err;
fh_init(&fh, NFS3_FHSIZE);
err = compose_entry_fh(cd, &fh, name, namlen); err = compose_entry_fh(cd, &fh, name, namlen);
if (err) { if (err) {
*p++ = 0; *p++ = 0;
*p++ = 0; *p++ = 0;
return p; goto out;
} }
p = encode_post_op_attr(cd->rqstp, p, &fh); p = encode_post_op_attr(cd->rqstp, p, &fh);
*p++ = xdr_one; /* yes, a file handle follows */ *p++ = xdr_one; /* yes, a file handle follows */
p = encode_fh(p, &fh); p = encode_fh(p, &fh);
out:
fh_put(&fh); fh_put(&fh);
return p; return p;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册