diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2013-07-29 18:51:43 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2013-07-29 18:51:43 +0000 |
commit | 019b846f60fb78199fb23f6f55b2b8c6d1127287 (patch) | |
tree | 3373c6159263fb68f19eccc2fd8688a557b1772f /sys | |
parent | 2643e41ac6303fc2c007c2b32ade1683ff9695c2 (diff) |
Do a proper cleanup in the error path when opening a clonable device fails.
ok guenther@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/spec_vnops.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/sys/kern/spec_vnops.c b/sys/kern/spec_vnops.c index e6c3eb6f41d..49d301de241 100644 --- a/sys/kern/spec_vnops.c +++ b/sys/kern/spec_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: spec_vnops.c,v 1.74 2013/07/09 15:37:43 beck Exp $ */ +/* $OpenBSD: spec_vnops.c,v 1.75 2013/07/29 18:51:42 kettenis Exp $ */ /* $NetBSD: spec_vnops.c,v 1.29 1996/04/22 01:42:38 christos Exp $ */ /* @@ -701,8 +701,10 @@ spec_open_clone(struct vop_open_args *ap) return (EBUSY); /* too many open instances */ error = cdevvp(makedev(major(vp->v_rdev), i), &cvp); - if (error) + if (error) { + clrbit(vp->v_specbitmap, i); return (error); /* out of vnodes */ + } VOP_UNLOCK(vp, 0, ap->a_p); @@ -712,8 +714,9 @@ spec_open_clone(struct vop_open_args *ap) vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, ap->a_p); if (error) { - clrbit(vp->v_specbitmap, i); - return (error); /* device open failed */ + vput(cvp); + clrbit(vp->v_specbitmap, i); + return (error); /* device open failed */ } cvp->v_flag |= VCLONE; |