From d3f0c37b796b02e05baf9d8270bd95d713d08b62 Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Thu, 24 Jul 2014 11:07:45 -0500 Subject: [PATCH] LINUX: Check afs_lookup return code explicitly 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 Tested-by: BuildBot Reviewed-by: D Brashear (cherry picked from commit 2edf5c0382385f898a017fd8e0e2429f8b2b3520) Change-Id: I7e123ab1cf88570a6b18e438e01409ed7804e014 Reviewed-on: http://gerrit.openafs.org/11558 Reviewed-by: Benjamin Kaduk Tested-by: BuildBot Reviewed-by: Stephan Wiesand --- src/afs/LINUX/osi_vnodeops.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c index 3ddcf422a..4d29efb55 100644 --- a/src/afs/LINUX/osi_vnodeops.c +++ b/src/afs/LINUX/osi_vnodeops.c @@ -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); -- 2.39.5