summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2018-03-05 03:31:40 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2018-03-05 03:31:40 +0000
commit68d14d3dada99517670b831378b34ef3984fce37 (patch)
tree72dc5a9fe3407372bf403510baa42b9f64654ad3 /sys
parent1c4b91c4c22e8eb0d1f42a5e8323cb58f8e4c698 (diff)
fix a memory leak in readdoslabel()
ok krw@
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/subr_disk.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/sys/kern/subr_disk.c b/sys/kern/subr_disk.c
index 093c3458c73..f9a8d97cc85 100644
--- a/sys/kern/subr_disk.c
+++ b/sys/kern/subr_disk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr_disk.c,v 1.232 2017/08/07 11:50:58 kettenis Exp $ */
+/* $OpenBSD: subr_disk.c,v 1.233 2018/03/05 03:31:39 jsg Exp $ */
/* $NetBSD: subr_disk.c,v 1.17 1996/03/16 23:17:08 christos Exp $ */
/*
@@ -387,15 +387,12 @@ readdoslabel(struct buf *bp, void (*strat)(struct buf *),
if (error == 0) {
dospartoff = DL_GETBSTART(gptlp);
dospartend = DL_GETBEND(gptlp);
- if (partoffp) {
- if (dospartoff == 0)
- return (ENXIO);
- else
- goto notfat;
- }
- *lp = *gptlp;
+ if (partoffp == 0)
+ *lp = *gptlp;
free(gptlp, M_DEVBUF,
sizeof(struct disklabel));
+ if (partoffp && dospartoff == 0)
+ return (ENXIO);
goto notfat;
} else {
free(gptlp, M_DEVBUF,