Skip to contentSkip to conversation

nfsd: remove some dead code in nfsd_create_locked()

PATCH In review Dan Carpenter 2 participants 2 messages Aug 3, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nfsd: remove some dead code in nfsd_create_locked()

We changed this around in f13058a93484 ('nfsd: reorganize nfsd_create') so "dchild" can't be an error pointer any more. Also we don't need to test if dchild is NULL because dput has a check built-in. Can it even be NULL?

fs/nfsd/vfs.c +2 -3
index c844fd6..cd628ce 100644
@@ -1141,7 +1141,7 @@ nfsd_create_locked(struct svc_rqst *rqstp, struct svc_fh *fhp,
 		char *fname, int flen, struct iattr *iap,
 		int type, dev_t rdev, struct svc_fh *resfhp)
 {
-	struct dentry	*dentry, *dchild = NULL;
+	struct dentry	*dentry, *dchild;
 	struct inode	*dirp;
 	__be32		err;
 	__be32		err2;
@@ -1208,8 +1208,7 @@ nfsd_create_locked(struct svc_rqst *rqstp, struct svc_fh *fhp,
 	if (!err)
 		err = fh_update(resfhp);
 out:
-	if (dchild && !IS_ERR(dchild))
-		dput(dchild);
+	dput(dchild);
 	return err;
 
 out_nfserr:
#1 lore raw
Quoted 3 lines · Dan Carpenter

We changed this around in f13058a93484 ('nfsd: reorganize nfsd_create') so "dchild" can't be an error pointer any more. Also we don't need to test if dchild is NULL because dput has a check built-in.

Thanks!

Quoted 1 line

Can it even be NULL?

It was returned from a caller's lookup_one_len, which can only return pointers or errors, I believe. (And looks like callers also do fh_verify and would already oops if it was null.)

Anyway, added a brief comment to that effect, fixed up the referenced commitid (I rewrote some history there, apologies) and committed, will push out after a few tests....

--b.

Quoted 26 lines
fs/nfsd/vfs.c +2 -3
index c844fd6..cd628ce 100644
@@ -1141,7 +1141,7 @@ nfsd_create_locked(struct svc_rqst *rqstp, struct svc_fh *fhp,
 		char *fname, int flen, struct iattr *iap,
 		int type, dev_t rdev, struct svc_fh *resfhp)
 {
-	struct dentry	*dentry, *dchild = NULL;
+	struct dentry	*dentry, *dchild;
 	struct inode	*dirp;
 	__be32		err;
 	__be32		err2;
@@ -1208,8 +1208,7 @@ nfsd_create_locked(struct svc_rqst *rqstp, struct svc_fh *fhp,
 	if (!err)
 		err = fh_update(resfhp);
 out:
-	if (dchild && !IS_ERR(dchild))
-		dput(dchild);
+	dput(dchild);
 	return err;
 
 out_nfserr: