Skip to content

Commit 2c231c0

Browse files
wenwenwang1vinodkoul
authored andcommitted
dmaengine: ti: dma-crossbar: Fix a memory leak bug
In ti_dra7_xbar_probe(), 'rsv_events' is allocated through kcalloc(). Then of_property_read_u32_array() is invoked to search for the property. However, if this process fails, 'rsv_events' is not deallocated, leading to a memory leak bug. To fix this issue, free 'rsv_events' before returning the error. Signed-off-by: Wenwen Wang <[email protected]> Acked-by: Peter Ujfalusi <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent d1abaeb commit 2c231c0

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/dma/ti/dma-crossbar.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,8 +391,10 @@ static int ti_dra7_xbar_probe(struct platform_device *pdev)
391391

392392
ret = of_property_read_u32_array(node, pname, (u32 *)rsv_events,
393393
nelm * 2);
394-
if (ret)
394+
if (ret) {
395+
kfree(rsv_events);
395396
return ret;
397+
}
396398

397399
for (i = 0; i < nelm; i++) {
398400
ti_dra7_xbar_reserve(rsv_events[i][0], rsv_events[i][1],

0 commit comments

Comments
 (0)