Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev Get out of cgd_detach() early on error. Do not call...
details: https://anonhg.NetBSD.org/src/rev/4835b70719d6
branches: trunk
changeset: 750988:4835b70719d6
user: dyoung <dyoung%NetBSD.org@localhost>
date: Wed Jan 20 18:55:17 2010 +0000
description:
Get out of cgd_detach() early on error. Do not call disk_destroy(9)
on error, that leaves the cgd_softc in an inconsistent state.
Fixes a crash during shutdown reported by Patrick Welche. Thanks
to Patrick for reporting and for testing the fix.
diffstat:
sys/dev/cgd.c | 28 +++++++++++++---------------
1 files changed, 13 insertions(+), 15 deletions(-)
diffs (53 lines):
diff -r 08fbf3d9340e -r 4835b70719d6 sys/dev/cgd.c
--- a/sys/dev/cgd.c Wed Jan 20 18:13:40 2010 +0000
+++ b/sys/dev/cgd.c Wed Jan 20 18:55:17 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cgd.c,v 1.66 2010/01/12 23:49:34 dyoung Exp $ */
+/* $NetBSD: cgd.c,v 1.67 2010/01/20 18:55:17 dyoung Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.66 2010/01/12 23:49:34 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.67 2010/01/20 18:55:17 dyoung Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -193,23 +193,21 @@
static int
cgd_detach(device_t self, int flags)
{
- int ret = 0;
- int pmask = 1 << RAW_PART;
+ int ret;
+ const int pmask = 1 << RAW_PART;
struct cgd_softc *sc = device_private(self);
- struct dk_softc *dksc;
+ struct dk_softc *dksc = &sc->sc_dksc;
+
+ if (DK_BUSY(dksc, pmask))
+ return EBUSY;
- dksc = &sc->sc_dksc;
- if ((dksc->sc_flags & DKF_INITED) != 0)
- {
- if (DK_BUSY(&sc->sc_dksc, pmask))
- ret = EBUSY;
- else
- ret = cgd_ioctl_clr(sc, curlwp);
- }
+ if ((dksc->sc_flags & DKF_INITED) != 0 &&
+ (ret = cgd_ioctl_clr(sc, curlwp)) != 0)
+ return ret;
- disk_destroy(&sc->sc_dksc.sc_dkdev);
+ disk_destroy(&dksc->sc_dkdev);
- return ret;
+ return 0;
}
void
Home |
Main Index |
Thread Index |
Old Index