summaryrefslogtreecommitdiff
path: root/sys/arch/sparc64/dev
diff options
context:
space:
mode:
authorTom Cosgrove <tom@cvs.openbsd.org>2016-10-13 18:40:48 +0000
committerTom Cosgrove <tom@cvs.openbsd.org>2016-10-13 18:40:48 +0000
commit972348acb67d78c36464d8aea7fa2be7a35de6e7 (patch)
treee4c6aa5a69c98a4fa89266fd6808b2c85e24d930 /sys/arch/sparc64/dev
parent229e90f9bfb60badd4f00b62ec41ca283ae1abdf (diff)
Fix another memory leak on error path in ldc.c
"right" deraadt@
Diffstat (limited to 'sys/arch/sparc64/dev')
-rw-r--r--sys/arch/sparc64/dev/ldc.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/sys/arch/sparc64/dev/ldc.c b/sys/arch/sparc64/dev/ldc.c
index 8ae9f0c13c2..9581d4f8255 100644
--- a/sys/arch/sparc64/dev/ldc.c
+++ b/sys/arch/sparc64/dev/ldc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ldc.c,v 1.13 2016/10/13 18:16:42 tom Exp $ */
+/* $OpenBSD: ldc.c,v 1.14 2016/10/13 18:40:47 tom Exp $ */
/*
* Copyright (c) 2009 Mark Kettenis
*
@@ -570,7 +570,7 @@ ldc_map_alloc(bus_dma_tag_t t, int nentries)
if (bus_dmamap_create(t, size, 1, size, 0,
BUS_DMA_NOWAIT | BUS_DMA_ALLOCNOW, &lm->lm_map) != 0)
- return (NULL);
+ goto error;
if (bus_dmamem_alloc(t, size, PAGE_SIZE, 0, &lm->lm_seg, 1,
&nsegs, BUS_DMA_NOWAIT) != 0)
@@ -595,6 +595,8 @@ free:
bus_dmamem_free(t, &lm->lm_seg, 1);
destroy:
bus_dmamap_destroy(t, lm->lm_map);
+error:
+ free(lm, M_DEVBUF, sizeof(struct ldc_map));
return (NULL);
}