patch-2.4.23 linux-2.4.23/drivers/sound/ad1889.c

Next file: linux-2.4.23/drivers/sound/ali5455.c
Previous file: linux-2.4.23/drivers/sound/ac97_plugin_wm97xx.c
Back to the patch index
Back to the overall index

diff -urN linux-2.4.22/drivers/sound/ad1889.c linux-2.4.23/drivers/sound/ad1889.c
@@ -236,16 +236,24 @@
 
 	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);
+	dev = NULL;
+	goto out;
 }
 
 static void ad1889_free_dev(ad1889_dev_t *dev)

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)