summaryrefslogtreecommitdiff
path: root/sys/scsi/sd.c
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2005-09-08 03:33:56 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2005-09-08 03:33:56 +0000
commit2a8a29d2410615b87763b56a5a77814b3917eb83 (patch)
tree6d3a72ee3dfe7dc559473a39636b3c81887f7f3b /sys/scsi/sd.c
parent60d35798c3b446bad4c5addeb48cbc3cca1fc5ed (diff)
free(NULL, ...) is not safe in the kernel. So check for NULL'ness
before free()'ing buf in sd_get_parms(). Tweak code so there is only one free(buf, ...) to worry about. ok deraadt@.
Diffstat (limited to 'sys/scsi/sd.c')
-rw-r--r--sys/scsi/sd.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/sys/scsi/sd.c b/sys/scsi/sd.c
index 7e5d583f277..cea8569a3b1 100644
--- a/sys/scsi/sd.c
+++ b/sys/scsi/sd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sd.c,v 1.90 2005/08/27 03:50:04 krw Exp $ */
+/* $OpenBSD: sd.c,v 1.91 2005/09/08 03:33:55 krw Exp $ */
/* $NetBSD: sd.c,v 1.111 1997/04/02 02:29:41 mycroft Exp $ */
/*-
@@ -1398,10 +1398,12 @@ sd_get_parms(sd, dp, flags)
}
validate:
- if (dp->disksize == 0) {
+ if (buf)
free(buf, M_TEMP);
+
+ if (dp->disksize == 0)
return (SDGP_RESULT_OFFLINE);
- }
+
if (ssblksize > 0)
dp->blksize = ssblksize;
else
@@ -1423,7 +1425,6 @@ validate:
default:
SC_DEBUG(sd->sc_link, SDEV_DB1,
("sd_get_parms: bad blksize: %#x\n", dp->blksize));
- free(buf, M_TEMP);
return (SDGP_RESULT_OFFLINE);
}
@@ -1445,7 +1446,6 @@ validate:
dp->cyls = (cyls == 0) ? dp->disksize / (dp->heads * dp->sectors) :
cyls;
- free(buf, M_TEMP);
return (SDGP_RESULT_OK);
}