* [PATCH 1/3] dmaengine: timb_dma: Return directly after a failed kzalloc() in td_alloc_init_desc()
2023-12-25 10:15 [PATCH 0/3] dmaengine: timb_dma: Adjustments for td_alloc_init_desc() Markus Elfring
@ 2023-12-25 10:18 ` Markus Elfring
2023-12-25 10:20 ` [PATCH 2/3] dmaengine: timb_dma: Improve a size determination " Markus Elfring
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Markus Elfring @ 2023-12-25 10:18 UTC (permalink / raw)
To: dmaengine, kernel-janitors, Vinod Koul; +Cc: LKML, cocci
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 25 Dec 2023 10:40:12 +0100
1. Return directly after a call of the function “kzalloc” failed
at the beginning.
2. Delete the label “out” which became unnecessary with this refactoring.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/dma/timb_dma.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/dma/timb_dma.c b/drivers/dma/timb_dma.c
index 7410025605e0..abcab0b1ad3b 100644
--- a/drivers/dma/timb_dma.c
+++ b/drivers/dma/timb_dma.c
@@ -327,7 +327,7 @@ static struct timb_dma_desc *td_alloc_init_desc(struct timb_dma_chan *td_chan)
td_desc = kzalloc(sizeof(struct timb_dma_desc), GFP_KERNEL);
if (!td_desc)
- goto out;
+ return NULL;
td_desc->desc_list_len = td_chan->desc_elems * TIMB_DMA_DESC_SIZE;
@@ -352,7 +352,6 @@ static struct timb_dma_desc *td_alloc_init_desc(struct timb_dma_chan *td_chan)
err:
kfree(td_desc->desc_list);
kfree(td_desc);
-out:
return NULL;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 2/3] dmaengine: timb_dma: Improve a size determination in td_alloc_init_desc()
2023-12-25 10:15 [PATCH 0/3] dmaengine: timb_dma: Adjustments for td_alloc_init_desc() Markus Elfring
2023-12-25 10:18 ` [PATCH 1/3] dmaengine: timb_dma: Return directly after a failed kzalloc() in td_alloc_init_desc() Markus Elfring
@ 2023-12-25 10:20 ` Markus Elfring
2023-12-25 10:22 ` [PATCH 3/3] dmaengine: timb_dma: One function call less in td_alloc_init_desc() after error detection Markus Elfring
2024-01-22 11:32 ` [PATCH 0/3] dmaengine: timb_dma: Adjustments for td_alloc_init_desc() Vinod Koul
3 siblings, 0 replies; 6+ messages in thread
From: Markus Elfring @ 2023-12-25 10:20 UTC (permalink / raw)
To: dmaengine, kernel-janitors, Vinod Koul; +Cc: LKML, cocci
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 25 Dec 2023 10:50:10 +0100
Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/dma/timb_dma.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/dma/timb_dma.c b/drivers/dma/timb_dma.c
index abcab0b1ad3b..fc1f67bf9c06 100644
--- a/drivers/dma/timb_dma.c
+++ b/drivers/dma/timb_dma.c
@@ -325,7 +325,7 @@ static struct timb_dma_desc *td_alloc_init_desc(struct timb_dma_chan *td_chan)
struct timb_dma_desc *td_desc;
int err;
- td_desc = kzalloc(sizeof(struct timb_dma_desc), GFP_KERNEL);
+ td_desc = kzalloc(sizeof(*td_desc), GFP_KERNEL);
if (!td_desc)
return NULL;
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/3] dmaengine: timb_dma: One function call less in td_alloc_init_desc() after error detection
2023-12-25 10:15 [PATCH 0/3] dmaengine: timb_dma: Adjustments for td_alloc_init_desc() Markus Elfring
2023-12-25 10:18 ` [PATCH 1/3] dmaengine: timb_dma: Return directly after a failed kzalloc() in td_alloc_init_desc() Markus Elfring
2023-12-25 10:20 ` [PATCH 2/3] dmaengine: timb_dma: Improve a size determination " Markus Elfring
@ 2023-12-25 10:22 ` Markus Elfring
2024-01-22 11:32 ` [PATCH 0/3] dmaengine: timb_dma: Adjustments for td_alloc_init_desc() Vinod Koul
3 siblings, 0 replies; 6+ messages in thread
From: Markus Elfring @ 2023-12-25 10:22 UTC (permalink / raw)
To: dmaengine, kernel-janitors, Vinod Koul; +Cc: LKML, cocci
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(-)
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);
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 0/3] dmaengine: timb_dma: Adjustments for td_alloc_init_desc()
2023-12-25 10:15 [PATCH 0/3] dmaengine: timb_dma: Adjustments for td_alloc_init_desc() Markus Elfring
` (2 preceding siblings ...)
2023-12-25 10:22 ` [PATCH 3/3] dmaengine: timb_dma: One function call less in td_alloc_init_desc() after error detection Markus Elfring
@ 2024-01-22 11:32 ` Vinod Koul
2024-01-22 12:15 ` [0/3] " Markus Elfring
3 siblings, 1 reply; 6+ messages in thread
From: Vinod Koul @ 2024-01-22 11:32 UTC (permalink / raw)
To: Markus Elfring; +Cc: dmaengine, kernel-janitors, LKML, cocci
On 25-12-23, 11:15, Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 25 Dec 2023 11:05:45 +0100
>
> A few update suggestions were taken into account
> from static source code analysis.
was this anaysis done by you or some tool reported this.
Frabkly I dont see much value in these patches, can you fix something
real please
>
> Markus Elfring (3):
> Return directly after a failed kzalloc()
> Improve a size determination
> One function call less after error detection
>
> drivers/dma/timb_dma.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> --
> 2.43.0
--
~Vinod
^ permalink raw reply [flat|nested] 6+ messages in thread