From: Thomas Veerman Date: Fri, 9 Dec 2011 15:47:42 +0000 (+0000) Subject: Properly unlock on mount failure X-Git-Tag: v3.2.0~188 X-Git-Url: http://zhaoyanbai.com/repos/icons/debian/static/ChangeLog.txt?a=commitdiff_plain;h=26d359a30c2cd02a4d5197ef240dd000d3082f32;p=minix.git Properly unlock on mount failure --- diff --git a/servers/avfs/mount.c b/servers/avfs/mount.c index f8457a2d4..36853ccbd 100644 --- a/servers/avfs/mount.c +++ b/servers/avfs/mount.c @@ -237,20 +237,27 @@ char mount_label[LABEL_MAX] ) } } -/* XXX: move this upwards before lookup after proper locking. */ /* We'll need a vnode for the root inode */ if ((root_node = get_free_vnode()) == NULL || dev == 266) { - unlock_vnode(vp); + if (vp != NULL) { + unlock_vnode(vp); + put_vnode(vp); + } unlock_vmnt(new_vmp); - put_vnode(vp); return(err_code); } - lock_vnode(root_node, VNODE_OPCL); /* Record process as a system process */ - if (isokendpt(fs_e, &slot) != OK) + if (isokendpt(fs_e, &slot) != OK) { + if (vp != NULL) { + unlock_vnode(vp); + put_vnode(vp); + } + unlock_vnode(root_node); + unlock_vmnt(new_vmp); return(EINVAL); + } rfp = &fproc[slot]; rfp->fp_flags |= FP_SYS_PROC; /* Process is an FS */ @@ -269,9 +276,11 @@ char mount_label[LABEL_MAX] ) new_vmp->m_fs_e = NONE; new_vmp->m_dev = NO_DEV; unlock_vnode(root_node); - unlock_vnode(vp); + if (vp != NULL) { + unlock_vnode(vp); + put_vnode(vp); + } unlock_vmnt(new_vmp); - put_vnode(vp); return(r); }