From dbf56739a3a0ae5216a124ecb64dca908ab93f61 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fran=C3=A7ois=20Romieu?= Date: Sat, 12 Jul 2003 00:17:15 -0700 Subject: [PATCH] [PATCH] Fix error path in AD1889 driver Memory leak fix: the allocated areas weren't referenced any more once the original error path returned. --- sound/oss/ad1889.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/sound/oss/ad1889.c b/sound/oss/ad1889.c index a55ade032da6..08aa241cd41d 100644 --- a/sound/oss/ad1889.c +++ b/sound/oss/ad1889.c @@ -236,16 +236,23 @@ static ad1889_dev_t *ad1889_alloc_dev(struct pci_dev *pci) for (i = 0; i < AD_MAX_STATES; i++) { dmabuf = &dev->state[i].dmabuf; - if ((dmabuf->rawbuf = kmalloc(DMA_SIZE, GFP_KERNEL|GFP_DMA)) == NULL) - return NULL; + dmabuf->rawbuf = kmalloc(DMA_SIZE, GFP_KERNEL|GFP_DMA); + if (!dmabuf->rawbuf) + goto err_free_dmabuf; dmabuf->rawbuf_size = DMA_SIZE; dmabuf->dma_handle = 0; dmabuf->rd_ptr = dmabuf->wr_ptr = dmabuf->dma_len = 0UL; dmabuf->ready = 0; dmabuf->rate = 44100; } - +out: return dev; + +err_free_dmabuf: + while (--i >= 0) + kfree(dev->state[i].dmabuf.rawbuf); + kfree(dev); + return NULL; } static void ad1889_free_dev(ad1889_dev_t *dev) -- 2.39.5