diff mbox series

[3/3] dmaengine: timb_dma: One function call less in td_alloc_init_desc() after error detection

Message ID 3184e80d-9056-4a0f-b0c0-8c1fefa62196@web.de (mailing list archive)
State Rejected
Headers show
Series dmaengine: timb_dma: Adjustments for td_alloc_init_desc() | expand

Commit Message

Markus Elfring Dec. 25, 2023, 10:22 a.m. UTC
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 25 Dec 2023 10:55:52 +0100

The kfree() function was called in one case by the
td_alloc_init_desc() function during error handling
even if the passed data structure member contained a null pointer.
This issue was detected by using the Coccinelle software.

Thus use another label.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/dma/timb_dma.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--
2.43.0
diff mbox series

Patch

diff --git a/drivers/dma/timb_dma.c b/drivers/dma/timb_dma.c
index fc1f67bf9c06..831c67af0237 100644
--- a/drivers/dma/timb_dma.c
+++ b/drivers/dma/timb_dma.c
@@ -333,7 +333,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)
-		goto err;
+		goto free_td_desc;

 	dma_async_tx_descriptor_init(&td_desc->txd, chan);
 	td_desc->txd.tx_submit = td_tx_submit;
@@ -351,4 +351,5 @@  static struct timb_dma_desc *td_alloc_init_desc(struct timb_dma_chan *td_chan)
 	return td_desc;
 err:
 	kfree(td_desc->desc_list);
+free_td_desc:
 	kfree(td_desc);