[2637] | 1 | From 100e35ed19e2c255986cb330b0f56f706acc6e7b Mon Sep 17 00:00:00 2001 |
---|
| 2 | From: Andrew Deason <adeason@sinenomine.net> |
---|
| 3 | Date: Thu, 24 Jul 2014 11:07:45 -0500 |
---|
| 4 | Subject: [PATCH] LINUX: Check afs_lookup return code explicitly |
---|
| 5 | |
---|
| 6 | Checking if the returned vcache is NULL or not is a bit of an indirect |
---|
| 7 | way to check if an error occurred. Just check the return code itself, |
---|
| 8 | to make sure we notice if any kind of error is reported. |
---|
| 9 | |
---|
| 10 | Suggested by Chas Williams. |
---|
| 11 | |
---|
| 12 | Reviewed-on: http://gerrit.openafs.org/11321 |
---|
| 13 | Reviewed-by: Chas Williams - CONTRACTOR <chas@cmf.nrl.navy.mil> |
---|
| 14 | Tested-by: BuildBot <buildbot@rampaginggeek.com> |
---|
| 15 | Reviewed-by: D Brashear <shadow@your-file-system.com> |
---|
| 16 | (cherry picked from commit 2edf5c0382385f898a017fd8e0e2429f8b2b3520) |
---|
| 17 | |
---|
| 18 | Change-Id: I7e123ab1cf88570a6b18e438e01409ed7804e014 |
---|
| 19 | --- |
---|
| 20 | src/afs/LINUX/osi_vnodeops.c | 9 +++++---- |
---|
| 21 | 1 file changed, 5 insertions(+), 4 deletions(-) |
---|
| 22 | |
---|
| 23 | diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c |
---|
| 24 | index 7e5cdd1..9ed6f01 100644 |
---|
| 25 | --- a/src/afs/LINUX/osi_vnodeops.c |
---|
| 26 | +++ b/src/afs/LINUX/osi_vnodeops.c |
---|
| 27 | @@ -943,6 +943,7 @@ check_bad_parent(struct dentry *dp) |
---|
| 28 | cred_t *credp; |
---|
| 29 | struct dentry *parent; |
---|
| 30 | struct vcache *vcp, *pvc, *avc = NULL; |
---|
| 31 | + int code; |
---|
| 32 | |
---|
| 33 | vcp = VTOAFS(dp->d_inode); |
---|
| 34 | parent = dget_parent(dp); |
---|
| 35 | @@ -952,8 +953,8 @@ check_bad_parent(struct dentry *dp) |
---|
| 36 | credp = crref(); |
---|
| 37 | |
---|
| 38 | /* force a lookup, so vcp->mvid is fixed up */ |
---|
| 39 | - afs_lookup(pvc, (char *)dp->d_name.name, &avc, credp); |
---|
| 40 | - if (!avc || vcp != avc) { /* bad, very bad.. */ |
---|
| 41 | + code = afs_lookup(pvc, (char *)dp->d_name.name, &avc, credp); |
---|
| 42 | + if (code || vcp != avc) { /* bad, very bad.. */ |
---|
| 43 | afs_Trace4(afs_iclSetp, CM_TRACE_TMP_1S3L, ICL_TYPE_STRING, |
---|
| 44 | "check_bad_parent: bad pointer returned from afs_lookup origvc newvc dentry", |
---|
| 45 | ICL_TYPE_POINTER, vcp, ICL_TYPE_POINTER, avc, |
---|
| 46 | @@ -1233,7 +1234,7 @@ afs_linux_dentry_revalidate(struct dentry *dp, int flags) |
---|
| 47 | |
---|
| 48 | credp = crref(); |
---|
| 49 | code = afs_lookup(pvcp, (char *)dp->d_name.name, &tvc, credp); |
---|
| 50 | - if (!tvc || tvc != vcp) { |
---|
| 51 | + if (code || tvc != vcp) { |
---|
| 52 | dput(parent); |
---|
| 53 | /* Force unhash; the name doesn't point to this file |
---|
| 54 | * anymore. */ |
---|
| 55 | @@ -1478,7 +1479,7 @@ afs_linux_lookup(struct inode *dip, struct dentry *dp) |
---|
| 56 | AFS_GLOCK(); |
---|
| 57 | code = afs_lookup(VTOAFS(dip), (char *)comp, &vcp, credp); |
---|
| 58 | |
---|
| 59 | - if (vcp) { |
---|
| 60 | + if (!code) { |
---|
| 61 | struct vattr *vattr = NULL; |
---|
| 62 | struct vcache *parent_vc = VTOAFS(dip); |
---|
| 63 | |
---|
| 64 | -- |
---|
| 65 | 2.1.2 |
---|
| 66 | |
---|