Skip to content

Commit

Permalink
dmaengine: ti: dma-crossbar: Fix a memory leak bug
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
wenwenwang1 authored and vinodkoul committed Aug 20, 2019
1 parent d1abaeb commit 2c231c0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/dma/ti/dma-crossbar.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,10 @@ static int ti_dra7_xbar_probe(struct platform_device *pdev)

ret = of_property_read_u32_array(node, pname, (u32 *)rsv_events,
nelm * 2);
if (ret)
if (ret) {
kfree(rsv_events);
return ret;
}

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

0 comments on commit 2c231c0

Please sign in to comment.