summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2005-11-17 23:58:42 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2005-11-17 23:58:42 +0000
commit64a145823a888809d18469fc425979f77b3fa5bb (patch)
treefdf10866e88bc49a841cb521cc039ca5b3b90f8d
parent21878d746ae25676d721f3bec593b44dbfa840e1 (diff)
Don't forget to device_unref() in sdclose() if sdlock() fails; ok krw@
-rw-r--r--sys/scsi/sd.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/sys/scsi/sd.c b/sys/scsi/sd.c
index 1b00e577c6b..ebf18ab7be3 100644
--- a/sys/scsi/sd.c
+++ b/sys/scsi/sd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sd.c,v 1.99 2005/11/17 21:25:58 krw Exp $ */
+/* $OpenBSD: sd.c,v 1.100 2005/11/17 23:58:41 miod Exp $ */
/* $NetBSD: sd.c,v 1.111 1997/04/02 02:29:41 mycroft Exp $ */
/*-
@@ -475,8 +475,10 @@ sdclose(dev, flag, fmt, p)
if (sd == NULL)
return ENXIO;
- if ((error = sdlock(sd)) != 0)
- return error;
+ if ((error = sdlock(sd)) != 0) {
+ device_unref(&sd->sc_dev);
+ return (error);
+ }
switch (fmt) {
case S_IFCHR: