summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2009-11-15 13:32:05 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2009-11-15 13:32:05 +0000
commit6446a2b9afe587bc50d6aacd613e231aa0114d90 (patch)
treeb3f0f6d00bcc69e9ee2525807986f71757af8b13 /sys/dev
parent5b1174a5033dde9064a797bb72b0651759b15435 (diff)
Fix memory leak in error case. Found by Parfait.
ok marco@ deraadt@
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/softraid.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/sys/dev/softraid.c b/sys/dev/softraid.c
index d54e27078ad..1a76d4dc50c 100644
--- a/sys/dev/softraid.c
+++ b/sys/dev/softraid.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraid.c,v 1.177 2009/10/29 15:21:31 jsing Exp $ */
+/* $OpenBSD: softraid.c,v 1.178 2009/11/15 13:32:04 jsing Exp $ */
/*
* Copyright (c) 2007, 2008, 2009 Marco Peereboom <marco@peereboom.us>
* Copyright (c) 2008 Chris Kuethe <ckuethe@openbsd.org>
@@ -852,8 +852,8 @@ sr_meta_native_bootprobe(struct sr_softc *sc, struct device *dv,
{
struct vnode *vn;
struct disklabel label;
- struct sr_metadata *md;
- struct sr_discipline *fake_sd;
+ struct sr_metadata *md = NULL;
+ struct sr_discipline *fake_sd = NULL;
struct sr_metadata_list *mle;
char devname[32];
dev_t dev, devr;
@@ -913,7 +913,7 @@ sr_meta_native_bootprobe(struct sr_softc *sc, struct device *dv,
if (fake_sd == NULL) {
printf("%s: not enough memory for fake discipline\n",
DEVNAME(sc));
- goto nosd;
+ goto done;
}
fake_sd->sd_sc = sc;
fake_sd->sd_meta_type = SR_META_F_NATIVE;
@@ -976,10 +976,12 @@ sr_meta_native_bootprobe(struct sr_softc *sc, struct device *dv,
vput(vn);
}
- free(fake_sd, M_DEVBUF);
-nosd:
- free(md, M_DEVBUF);
done:
+ if (fake_sd)
+ free(fake_sd, M_DEVBUF);
+ if (md)
+ free(md, M_DEVBUF);
+
return (rv);
}