Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev Don't sprinkle cleanup code here and there (necessar...
details: https://anonhg.NetBSD.org/src/rev/bb5398a665d0
branches: trunk
changeset: 534441:bb5398a665d0
user: enami <enami%NetBSD.org@localhost>
date: Fri Jul 26 06:16:32 2002 +0000
description:
Don't sprinkle cleanup code here and there (necessary cleanup was missed).
diffstat:
sys/dev/vnd.c | 47 ++++++++++++++++++++---------------------------
1 files changed, 20 insertions(+), 27 deletions(-)
diffs (105 lines):
diff -r df51b222a08d -r bb5398a665d0 sys/dev/vnd.c
--- a/sys/dev/vnd.c Fri Jul 26 06:04:57 2002 +0000
+++ b/sys/dev/vnd.c Fri Jul 26 06:16:32 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vnd.c,v 1.82 2002/07/21 15:32:18 hannken Exp $ */
+/* $NetBSD: vnd.c,v 1.83 2002/07/26 06:16:32 enami Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -98,7 +98,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.82 2002/07/21 15:32:18 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.83 2002/07/26 06:16:32 enami Exp $");
#if defined(_KERNEL_OPT)
#include "fs_nfs.h"
@@ -763,18 +763,12 @@
* have to worry about them.
*/
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, vio->vnd_file, p);
- if ((error = vn_open(&nd, FREAD|FWRITE, 0)) != 0) {
- vndunlock(vnd);
- return(error);
- }
+ if ((error = vn_open(&nd, FREAD|FWRITE, 0)) != 0)
+ goto unlock_and_exit;
error = VOP_GETATTR(nd.ni_vp, &vattr, p->p_ucred, p);
- if (error) {
- VOP_UNLOCK(nd.ni_vp, 0);
- (void) vn_close(nd.ni_vp, FREAD|FWRITE, p->p_ucred, p);
- vndunlock(vnd);
- return(error);
- }
VOP_UNLOCK(nd.ni_vp, 0);
+ if (error)
+ goto close_and_exit;
vnd->sc_vp = nd.ni_vp;
vnd->sc_size = btodb(vattr.va_size); /* note truncation */
@@ -794,10 +788,8 @@
*/
if (vnd->sc_geom.vng_secsize < DEV_BSIZE ||
(vnd->sc_geom.vng_secsize % DEV_BSIZE) != 0) {
- (void) vn_close(nd.ni_vp, FREAD|FWRITE,
- p->p_ucred, p);
- vndunlock(vnd);
- return (EINVAL);
+ error = EINVAL;
+ goto close_and_exit;
}
/*
@@ -814,10 +806,8 @@
* geometry.
*/
if (vnd->sc_size < geomsize) {
- (void) vn_close(nd.ni_vp, FREAD|FWRITE,
- p->p_ucred, p);
- vndunlock(vnd);
- return (EINVAL);
+ error = EINVAL;
+ goto close_and_exit;
}
} else {
/*
@@ -825,8 +815,8 @@
* (1M) in order to use this geometry.
*/
if (vnd->sc_size < (32 * 64)) {
- vndunlock(vnd);
- return (EINVAL);
+ error = EINVAL;
+ goto close_and_exit;
}
vnd->sc_geom.vng_secsize = DEV_BSIZE;
@@ -847,11 +837,8 @@
*/
vnd->sc_size = geomsize;
- if ((error = vndsetcred(vnd, p->p_ucred)) != 0) {
- (void) vn_close(nd.ni_vp, FREAD|FWRITE, p->p_ucred, p);
- vndunlock(vnd);
- return(error);
- }
+ if ((error = vndsetcred(vnd, p->p_ucred)) != 0)
+ goto close_and_exit;
vndthrottle(vnd, vnd->sc_vp);
vio->vnd_size = dbtob(vnd->sc_size);
vnd->sc_flags |= VNF_INITED;
@@ -884,6 +871,12 @@
break;
+close_and_exit:
+ (void) vn_close(nd.ni_vp, FREAD|FWRITE, p->p_ucred, p);
+unlock_and_exit:
+ vndunlock(vnd);
+ return (error);
+
case VNDIOCCLR:
if ((error = vndlock(vnd)) != 0)
return (error);
Home |
Main Index |
Thread Index |
Old Index