From a7571c3f6bf639f51a73fb6d21702a1e1aeccc32 Mon Sep 17 00:00:00 2001 From: Alexander Leidinger Date: Sat, 21 Jan 2006 11:50:56 +0000 Subject: [PATCH] Prevent dereferencing a NULL pointer if the malloc() fails. CID: 219 Found with: Coverity Prevent(tm) --- sys/dev/sound/pci/maestro.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/sys/dev/sound/pci/maestro.c b/sys/dev/sound/pci/maestro.c index 6f1a4c5d56c..8b97173dd50 100644 --- a/sys/dev/sound/pci/maestro.c +++ b/sys/dev/sound/pci/maestro.c @@ -1928,18 +1928,19 @@ agg_attach(device_t dev) bus_release_resource(dev, SYS_RES_IRQ, irqid, irq); if (reg != NULL) bus_release_resource(dev, SYS_RES_IOPORT, regid, reg); - if (ess->stat != NULL) - dma_free(ess->stat_dmat, ess->stat); - if (ess->stat_dmat != NULL) - bus_dma_tag_destroy(ess->stat_dmat); - if (ess->buf_dmat != NULL) - bus_dma_tag_destroy(ess->buf_dmat); + if (ess != NULL) { + if (ess->stat != NULL) + dma_free(ess->stat_dmat, ess->stat); + if (ess->stat_dmat != NULL) + bus_dma_tag_destroy(ess->stat_dmat); + if (ess->buf_dmat != NULL) + bus_dma_tag_destroy(ess->buf_dmat); #ifdef USING_MUTEX - if (mtx_initialized(&ess->lock)) - mtx_destroy(&ess->lock); + if (mtx_initialized(&ess->lock)) + mtx_destroy(&ess->lock); #endif - if (ess != NULL) free(ess, M_DEVBUF); + } return ret; } -- 2.45.2