LINUX: Check afs_lookup return code explicitly
authorAndrew Deason <adeason@sinenomine.net>
Thu, 24 Jul 2014 16:07:45 +0000 (11:07 -0500)
committerStephan Wiesand <stephan.wiesand@desy.de>
Mon, 24 Nov 2014 09:14:05 +0000 (04:14 -0500)
Checking if the returned vcache is NULL or not is a bit of an indirect
way to check if an error occurred. Just check the return code itself,
to make sure we notice if any kind of error is reported.

Suggested by Chas Williams.

Reviewed-on: http://gerrit.openafs.org/11321
Reviewed-by: Chas Williams - CONTRACTOR <chas@cmf.nrl.navy.mil>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: D Brashear <shadow@your-file-system.com>
(cherry picked from commit 2edf5c0382385f898a017fd8e0e2429f8b2b3520)

Change-Id: I7e123ab1cf88570a6b18e438e01409ed7804e014
Reviewed-on: http://gerrit.openafs.org/11558
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>

src/afs/LINUX/osi_vnodeops.c

index 3ddcf42..4d29efb 100644 (file)
@@ -943,6 +943,7 @@ check_bad_parent(struct dentry *dp)
     cred_t *credp;
     struct dentry *parent;
     struct vcache *vcp, *pvc, *avc = NULL;
+    int code;
 
     vcp = VTOAFS(dp->d_inode);
     parent = dget_parent(dp);
@@ -952,8 +953,8 @@ check_bad_parent(struct dentry *dp)
        credp = crref();
 
        /* force a lookup, so vcp->mvid is fixed up */
-       afs_lookup(pvc, (char *)dp->d_name.name, &avc, credp);
-       if (!avc || vcp != avc) {       /* bad, very bad.. */
+       code = afs_lookup(pvc, (char *)dp->d_name.name, &avc, credp);
+       if (code || vcp != avc) {       /* bad, very bad.. */
            afs_Trace4(afs_iclSetp, CM_TRACE_TMP_1S3L, ICL_TYPE_STRING,
                       "check_bad_parent: bad pointer returned from afs_lookup origvc newvc dentry",
                       ICL_TYPE_POINTER, vcp, ICL_TYPE_POINTER, avc,
@@ -1233,7 +1234,7 @@ afs_linux_dentry_revalidate(struct dentry *dp, int flags)
 
            credp = crref();
            code = afs_lookup(pvcp, (char *)dp->d_name.name, &tvc, credp);
-           if (!tvc || tvc != vcp) {
+           if (code || tvc != vcp) {
                dput(parent);
                /* Force unhash; the name doesn't point to this file
                 * anymore. */
@@ -1478,7 +1479,7 @@ afs_linux_lookup(struct inode *dip, struct dentry *dp)
     AFS_GLOCK();
     code = afs_lookup(VTOAFS(dip), (char *)comp, &vcp, credp);
     
-    if (vcp) {
+    if (!code) {
        struct vattr *vattr = NULL;
        struct vcache *parent_vc = VTOAFS(dip);