call extent_free_region_descriptor(ex, myrp) when ltseep() returns non-zero

(eg if interrupted).
Fixes Coverty CIDs 1555 and 1556.
This commit is contained in:
dsl 2006-04-02 09:27:05 +00:00
parent c89fb86a25
commit 114adc27fb
1 changed files with 14 additions and 12 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: subr_extent.c,v 1.55 2006/03/08 04:43:00 thorpej Exp $ */ /* $NetBSD: subr_extent.c,v 1.56 2006/04/02 09:27:05 dsl Exp $ */
/*- /*-
* Copyright (c) 1996, 1998 The NetBSD Foundation, Inc. * Copyright (c) 1996, 1998 The NetBSD Foundation, Inc.
@ -41,7 +41,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: subr_extent.c,v 1.55 2006/03/08 04:43:00 thorpej Exp $"); __KERNEL_RCSID(0, "$NetBSD: subr_extent.c,v 1.56 2006/04/02 09:27:05 dsl Exp $");
#ifdef _KERNEL #ifdef _KERNEL
#include "opt_lockdebug.h" #include "opt_lockdebug.h"
@ -593,13 +593,14 @@ extent_alloc_region(struct extent *ex, u_long start, u_long size, int flags)
error = ltsleep(ex, error = ltsleep(ex,
PNORELOCK | PRIBIO | ((flags & EX_CATCH) ? PCATCH : 0), PNORELOCK | PRIBIO | ((flags & EX_CATCH) ? PCATCH : 0),
"extnt", 0, &ex->ex_slock); "extnt", 0, &ex->ex_slock);
if (error) if (error == 0)
return (error); goto alloc_start;
goto alloc_start; } else {
simple_unlock(&ex->ex_slock);
error = EAGAIN;
} }
extent_free_region_descriptor(ex, myrp); extent_free_region_descriptor(ex, myrp);
simple_unlock(&ex->ex_slock); return error;
return (EAGAIN);
} }
/* /*
* We don't conflict, but this region lies before * We don't conflict, but this region lies before
@ -984,14 +985,15 @@ skip:
error = ltsleep(ex, error = ltsleep(ex,
PNORELOCK | PRIBIO | ((flags & EX_CATCH) ? PCATCH : 0), PNORELOCK | PRIBIO | ((flags & EX_CATCH) ? PCATCH : 0),
"extnt", 0, &ex->ex_slock); "extnt", 0, &ex->ex_slock);
if (error) if (error == 0)
return (error); goto alloc_start;
goto alloc_start; } else {
simple_unlock(&ex->ex_slock);
error = EAGAIN;
} }
extent_free_region_descriptor(ex, myrp); extent_free_region_descriptor(ex, myrp);
simple_unlock(&ex->ex_slock); return error;
return (EAGAIN);
found: found:
/* /*