Commit dbf56739 authored by François Romieu's avatar François Romieu Committed by Linus Torvalds

[PATCH] Fix error path in AD1889 driver

Memory leak fix: the allocated areas weren't referenced any more once the
original error path returned.
parent 008a71d2
...@@ -236,16 +236,23 @@ static ad1889_dev_t *ad1889_alloc_dev(struct pci_dev *pci) ...@@ -236,16 +236,23 @@ static ad1889_dev_t *ad1889_alloc_dev(struct pci_dev *pci)
for (i = 0; i < AD_MAX_STATES; i++) { for (i = 0; i < AD_MAX_STATES; i++) {
dmabuf = &dev->state[i].dmabuf; dmabuf = &dev->state[i].dmabuf;
if ((dmabuf->rawbuf = kmalloc(DMA_SIZE, GFP_KERNEL|GFP_DMA)) == NULL) dmabuf->rawbuf = kmalloc(DMA_SIZE, GFP_KERNEL|GFP_DMA);
return NULL; if (!dmabuf->rawbuf)
goto err_free_dmabuf;
dmabuf->rawbuf_size = DMA_SIZE; dmabuf->rawbuf_size = DMA_SIZE;
dmabuf->dma_handle = 0; dmabuf->dma_handle = 0;
dmabuf->rd_ptr = dmabuf->wr_ptr = dmabuf->dma_len = 0UL; dmabuf->rd_ptr = dmabuf->wr_ptr = dmabuf->dma_len = 0UL;
dmabuf->ready = 0; dmabuf->ready = 0;
dmabuf->rate = 44100; dmabuf->rate = 44100;
} }
out:
return dev; 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) static void ad1889_free_dev(ad1889_dev_t *dev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment