afs: Avoid panics on failed return from afs_CFileOpen
[openafs.git] / src / afs / VNOPS / afs_vnop_symlink.c
index f608b2b..e88e09e 100644 (file)
@@ -43,6 +43,7 @@ afs_DisconCreateSymlink(struct vcache *avc, char *aname,
     struct dcache *tdc;
     struct osi_file *tfile;
     afs_size_t offset, len;
+    int code = 0;
 
     tdc = afs_GetDCache(avc, 0, areq, &offset, &len, 0);
     if (!tdc) {
@@ -54,13 +55,18 @@ afs_DisconCreateSymlink(struct vcache *avc, char *aname,
     avc->f.m.Length = len;
 
     ObtainWriteLock(&tdc->lock, 720);
+    tfile = afs_CFileOpen(&tdc->f.inode);
+    if (!tfile) {
+       code = EIO;
+       goto done;
+    }
     afs_AdjustSize(tdc, len);
     tdc->validPos = len;
-    tfile = afs_CFileOpen(&tdc->f.inode);
     afs_CFileWrite(tfile, 0, aname, len);
     afs_CFileClose(tfile);
+ done:
     ReleaseWriteLock(&tdc->lock);
-    return 0;
+    return code;
 }
 
 /* don't set CDirty in here because RPC is called synchronously */
@@ -200,11 +206,7 @@ afs_symlink(OSI_VC_DECL(adp), char *aname, struct vattr *attrs,
     ObtainWriteLock(&afs_xvcache, 40);
     if (code) {
        if (code < 0) {
-           ObtainWriteLock(&afs_xcbhash, 499);
-           afs_DequeueCallback(adp);
-           adp->f.states &= ~CStatd;
-           ReleaseWriteLock(&afs_xcbhash);
-           osi_dnlc_purgedp(adp);
+           afs_StaleVCache(adp);
        }
        ReleaseWriteLock(&adp->lock);
        ReleaseWriteLock(&afs_xvcache);