Module Name: src
Committed By: pooka
Date: Thu Mar 26 20:05:07 UTC 2009
Modified Files:
src/sys/fs/hfs: hfs_subr.c libhfs.c
Log Message:
pretend to do some sort of cleanup in error branches
To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/fs/hfs/hfs_subr.c
cvs rdiff -u -r1.5 -r1.6 src/sys/fs/hfs/libhfs.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/fs/hfs/hfs_subr.c
diff -u src/sys/fs/hfs/hfs_subr.c:1.11 src/sys/fs/hfs/hfs_subr.c:1.12
--- src/sys/fs/hfs/hfs_subr.c:1.11 Sun Nov 16 19:34:30 2008
+++ src/sys/fs/hfs/hfs_subr.c Thu Mar 26 20:05:07 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: hfs_subr.c,v 1.11 2008/11/16 19:34:30 pooka Exp $ */
+/* $NetBSD: hfs_subr.c,v 1.12 2009/03/26 20:05:07 pooka Exp $ */
/*-
* Copyright (c) 2005, 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hfs_subr.c,v 1.11 2008/11/16 19:34:30 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hfs_subr.c,v 1.12 2009/03/26 20:05:07 pooka Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -156,7 +156,7 @@
hfs_libcb_data* cbdata = NULL;
hfs_libcb_argsopen* args;
struct partinfo dpart;
- int result;
+ int result, mode;
result = 0;
args = (hfs_libcb_argsopen*)(cbargs->openvol);
@@ -176,7 +176,8 @@
cbdata->devvp = NULL;
/* Open the device node. */
- if ((result = VOP_OPEN(args->devvp, vol->readonly? FREAD : FREAD|FWRITE,
+ mode = vol->readonly ? FREAD : FREAD|FWRITE;
+ if ((result = VOP_OPEN(args->devvp, mode,
FSCRED)) != 0)
goto error;
@@ -184,8 +185,10 @@
vn_lock(args->devvp, LK_EXCLUSIVE | LK_RETRY);
result = vinvalbuf(args->devvp, V_SAVE, args->cred, args->l, 0, 0);
VOP_UNLOCK(args->devvp, 0);
- if (result != 0)
+ if (result != 0) {
+ VOP_CLOSE(args->devvp, mode, FSCRED);
goto error;
+ }
cbdata->devvp = args->devvp;
Index: src/sys/fs/hfs/libhfs.c
diff -u src/sys/fs/hfs/libhfs.c:1.5 src/sys/fs/hfs/libhfs.c:1.6
--- src/sys/fs/hfs/libhfs.c:1.5 Tue Dec 11 12:04:23 2007
+++ src/sys/fs/hfs/libhfs.c Thu Mar 26 20:05:07 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: libhfs.c,v 1.5 2007/12/11 12:04:23 lukem Exp $ */
+/* $NetBSD: libhfs.c,v 1.6 2009/03/26 20:05:07 pooka Exp $ */
/*-
* Copyright (c) 2005, 2007 The NetBSD Foundation, Inc.
@@ -47,7 +47,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: libhfs.c,v 1.5 2007/12/11 12:04:23 lukem Exp $");
+__KERNEL_RCSID(0, "$NetBSD: libhfs.c,v 1.6 2009/03/26 20:05:07 pooka Exp $");
#include "libhfs.h"
@@ -161,6 +161,7 @@
void* buffer;
void* buffer2; /* used as temporary pointer for realloc() */
int result;
+ int isopen = 0;
result = 1;
buffer = NULL;
@@ -173,6 +174,7 @@
if(hfslib_openvoldevice(out_vol, in_device, cbargs) != 0)
HFS_LIBERR("could not open device");
+ isopen = 1;
/*
* Read the volume header.
@@ -353,6 +355,8 @@
/* FALLTHROUGH */
error:
+ if (isopen)
+ hfslib_close_volume(out_vol, cbargs);
if(buffer!=NULL)
hfslib_free(buffer, cbargs);