From ec415604ac113037fe5565b05ca713ac76ee24eb Mon Sep 17 00:00:00 2001 From: scottl Date: Sat, 14 Jan 2006 17:22:47 +0000 Subject: Free the newtag if we exit with a failure from alloc_bounce_zone(). Found by: Coverity Prevent(tm) --- sys/amd64/amd64/busdma_machdep.c | 4 +++- sys/i386/i386/busdma_machdep.c | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/sys/amd64/amd64/busdma_machdep.c b/sys/amd64/amd64/busdma_machdep.c index 199ab54..1d70417 100644 --- a/sys/amd64/amd64/busdma_machdep.c +++ b/sys/amd64/amd64/busdma_machdep.c @@ -285,8 +285,10 @@ bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment, /* Must bounce */ - if ((error = alloc_bounce_zone(newtag)) != 0) + if ((error = alloc_bounce_zone(newtag)) != 0) { + free(newtag, M_DEVBUF); return (error); + } bz = newtag->bounce_zone; if (ptoa(bz->total_bpages) < maxsize) { diff --git a/sys/i386/i386/busdma_machdep.c b/sys/i386/i386/busdma_machdep.c index c4af1dd..08db5e0 100644 --- a/sys/i386/i386/busdma_machdep.c +++ b/sys/i386/i386/busdma_machdep.c @@ -28,6 +28,9 @@ __FBSDID("$FreeBSD$"); #include +#include +#include +#include #include #include #include @@ -285,8 +288,10 @@ bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment, /* Must bounce */ - if ((error = alloc_bounce_zone(newtag)) != 0) + if ((error = alloc_bounce_zone(newtag)) != 0) { + free(newtag, M_DEVBUF); return (error); + } bz = newtag->bounce_zone; if (ptoa(bz->total_bpages) < maxsize) { -- cgit v1.1