drivers/ieee1394/ohci1394.c fix kzalloc error handling
PATCH 1/1 drivers/ieee1394/ohci1394.c fix kzalloc error handling
From: Florian Westphal <[email protected]>
Always kfree() d->prg_bus and d->buf_bus.
Make sure buf_bus/prg_bus are not NULL before using them.
Signed-off-by Florian Westphal <[email protected]>
---
alloc_dma_rcv_ctx() kzallocs a few bufs and calls free_dma_rcv_ctx() for cleanup in case an error occurs. free_dma_rcv_ctx() may handle such error conditions incorrect, e.g. if d->buf_bus is NULL.
Also, if the kzalloc for buf_cpu failed (but not buf_bus) buf_bus is not freed (same goes for prg_bus).
drivers/ieee1394/ohci1394.c +10 -6
@@ -2918,7 +2918,7 @@ static void free_dma_rcv_ctx(struct dma_DBGMSG ("Freeing dma_rcv_ctx %d" , d->ctx); -if (d->buf_cpu) { +if (d->buf_cpu && d->buf_bus) {for (i=0 ; i<d->num_desc; i++)if (d->buf_cpu[i] && d->buf_bus[i]) { pci_free_consistent(
@@ -2926,10 +2926,12 @@ static void free_dma_rcv_ctx(struct dma_ d->buf_cpu[i], d->buf_bus[i]);OHCI_DMA_FREE ("consistent dma_rcv buf[%d]" , i); } -kfree (d->buf_cpu); -kfree (d->buf_bus); } -if (d->prg_cpu) { + +kfree (d->buf_cpu); +kfree (d->buf_bus); + +if (d->prg_cpu && d->prg_bus) {for (i=0 ; i<d->num_desc; i++)if (d->prg_cpu[i] && d->prg_bus[i]) {pci_pool_free (d->prg_pool, d->prg_cpu[i], d->prg_bus[i]);
@@ -2937,9 +2939,11 @@ static void free_dma_rcv_ctx(struct dma_ }pci_pool_destroy (d->prg_pool);OHCI_DMA_FREE ("dma_rcv prg pool" ); -kfree (d->prg_cpu); -kfree (d->prg_bus); } + +kfree (d->prg_cpu); +kfree (d->prg_bus); +kfree (d->spb);/* Mark this context as freed. */
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors