From e7be9bf929560a1f033b2513915781920884954d Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Mon, 5 Nov 2012 23:47:06 -0600 Subject: [PATCH] afs_open: Deal with afs_GetDCache returning NULL afs_open was assuming afs_GetDCache always returned non-NULL. Make it deal with a NULL return. Reviewed-on: http://gerrit.openafs.org/8408 Tested-by: BuildBot Reviewed-by: Derrick Brashear (cherry picked from commit 595a614d76d84be602c07d519738556b7f9ebf2a) Change-Id: Iba54fd03a63be485490db33ff48e5642f55df52d Reviewed-on: http://gerrit.openafs.org/9500 Tested-by: BuildBot Reviewed-by: Derrick Brashear Reviewed-by: Andrew Deason Reviewed-by: Stephan Wiesand --- src/afs/VNOPS/afs_vnop_open.c | 43 ++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/src/afs/VNOPS/afs_vnop_open.c b/src/afs/VNOPS/afs_vnop_open.c index d5d54ce33..b6532c26b 100644 --- a/src/afs/VNOPS/afs_vnop_open.c +++ b/src/afs/VNOPS/afs_vnop_open.c @@ -170,28 +170,29 @@ afs_open(struct vcache **avcp, afs_int32 aflags, afs_ucred_t *acred) afs_size_t offset, len; tdc = afs_GetDCache(tvc, 0, &treq, &offset, &len, 1); - - ObtainSharedLock(&tdc->mflock, 865); - if (!(tdc->mflags & DFFetchReq)) { - struct brequest *bp; - - /* start the daemon (may already be running, however) */ - UpgradeSToWLock(&tdc->mflock, 666); - tdc->mflags |= DFFetchReq; /* guaranteed to be cleared by BKG or - GetDCache */ - /* last parm (1) tells bkg daemon to do an afs_PutDCache when it - is done, since we don't want to wait for it to finish before - doing so ourselves. - */ - bp = afs_BQueue(BOP_FETCH, tvc, B_DONTWAIT, 0, acred, - (afs_size_t) 0, (afs_size_t) 1, tdc, - (void *)0, (void *)0); - if (!bp) { - tdc->mflags &= ~DFFetchReq; + if (tdc) { + ObtainSharedLock(&tdc->mflock, 865); + if (!(tdc->mflags & DFFetchReq)) { + struct brequest *bp; + + /* start the daemon (may already be running, however) */ + UpgradeSToWLock(&tdc->mflock, 666); + tdc->mflags |= DFFetchReq; /* guaranteed to be cleared by BKG or + GetDCache */ + /* last parm (1) tells bkg daemon to do an afs_PutDCache when it + is done, since we don't want to wait for it to finish before + doing so ourselves. + */ + bp = afs_BQueue(BOP_FETCH, tvc, B_DONTWAIT, 0, acred, + (afs_size_t) 0, (afs_size_t) 1, tdc, + (void *)0, (void *)0); + if (!bp) { + tdc->mflags &= ~DFFetchReq; + } + ReleaseWriteLock(&tdc->mflock); + } else { + ReleaseSharedLock(&tdc->mflock); } - ReleaseWriteLock(&tdc->mflock); - } else { - ReleaseSharedLock(&tdc->mflock); } } done: -- 2.39.5