[patch 1/2] dma/timb_dma: fixup error handling in td_alloc_init_desc()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The original code tried to kfree(td_desc->desc_list) when td_desc was
NULL so I re-arranged it.

Signed-off-by: Dan Carpenter <error27@xxxxxxxxx>

diff --git a/drivers/dma/timb_dma.c b/drivers/dma/timb_dma.c
index 0172fa3..3e101a0 100644
--- a/drivers/dma/timb_dma.c
+++ b/drivers/dma/timb_dma.c
@@ -390,7 +390,7 @@ static struct timb_dma_desc *td_alloc_init_desc(struct timb_dma_chan *td_chan)
 	td_desc->desc_list = kzalloc(td_desc->desc_list_len, GFP_KERNEL);
 	if (!td_desc->desc_list) {
 		dev_err(chan2dev(chan), "Failed to alloc descriptor\n");
-		goto err;
+		goto err_desc;
 	}
 
 	dma_async_tx_descriptor_init(&td_desc->txd, chan);
@@ -403,14 +403,16 @@ static struct timb_dma_desc *td_alloc_init_desc(struct timb_dma_chan *td_chan)
 	err = dma_mapping_error(chan2dmadev(chan), td_desc->txd.phys);
 	if (err) {
 		dev_err(chan2dev(chan), "DMA mapping error: %d\n", err);
-		goto err;
+		goto err_list;
 	}
 
 	return td_desc;
-err:
+
+err_list:
 	kfree(td_desc->desc_list);
+err_desc:
 	kfree(td_desc);
-
+err:
 	return NULL;
 
 }
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux