From 2edf5c0382385f898a017fd8e0e2429f8b2b3520 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. Change-Id: I61cc7304e9885ddaaebe96db3b12457cb6224420 Reviewed-on: http://gerrit.openafs.org/11321 Reviewed-by: Chas Williams - CONTRACTOR Tested-by: BuildBot Reviewed-by: D Brashear --- 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 0c907d825..18d013a9c 100644 --- a/src/afs/LINUX/osi_vnodeops.c +++ b/src/afs/LINUX/osi_vnodeops.c @@ -964,10 +964,11 @@ static inline void fix_bad_parent(struct dentry *dp, cred_t *credp, struct vcache *vcp, struct vcache *pvc) { struct vcache *avc = NULL; + int code; /* 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, @@ -1302,7 +1303,7 @@ afs_linux_dentry_revalidate(struct dentry *dp, int flags) int code; 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. */ @@ -1550,7 +1551,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