pretend to do some sort of cleanup in error branches
This commit is contained in:
parent
d478d391f3
commit
f75bcfdea3
@ -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_opendev(
|
||||
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 @@ hfs_libcb_opendev(
|
||||
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 @@ hfs_libcb_opendev(
|
||||
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;
|
||||
|
||||
|
@ -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 @@ hfslib_open_volume(
|
||||
void* buffer;
|
||||
void* buffer2; /* used as temporary pointer for realloc() */
|
||||
int result;
|
||||
int isopen = 0;
|
||||
|
||||
result = 1;
|
||||
buffer = NULL;
|
||||
@ -173,6 +174,7 @@ hfslib_open_volume(
|
||||
|
||||
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 @@ hfslib_open_volume(
|
||||
|
||||
/* FALLTHROUGH */
|
||||
error:
|
||||
if (isopen)
|
||||
hfslib_close_volume(out_vol, cbargs);
|
||||
if(buffer!=NULL)
|
||||
hfslib_free(buffer, cbargs);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user