Skip to content

Commit 5c6c6d6

Browse files
kishonvinodkoul
authored andcommitted
dmaengine: ti: k3-udma: Set bchan to NULL if a channel request fail
bcdma_get_*() checks if bchan is already allocated by checking if it has a NON NULL value. For the error cases, bchan will have error value and bcdma_get_*() considers this as already allocated (PASS) since the error values are NON NULL. This results in NULL pointer dereference error while de-referencing bchan. Reset the value of bchan to NULL if a channel request fails. CC: [email protected] Acked-by: Peter Ujfalusi <[email protected]> Signed-off-by: Kishon Vijay Abraham I <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 2498363 commit 5c6c6d6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/dma/ti/k3-udma.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,6 +1348,7 @@ static int bcdma_get_bchan(struct udma_chan *uc)
13481348
{
13491349
struct udma_dev *ud = uc->ud;
13501350
enum udma_tp_level tpl;
1351+
int ret;
13511352

13521353
if (uc->bchan) {
13531354
dev_dbg(ud->dev, "chan%d: already have bchan%d allocated\n",
@@ -1365,8 +1366,11 @@ static int bcdma_get_bchan(struct udma_chan *uc)
13651366
tpl = ud->bchan_tpl.levels - 1;
13661367

13671368
uc->bchan = __udma_reserve_bchan(ud, tpl, -1);
1368-
if (IS_ERR(uc->bchan))
1369-
return PTR_ERR(uc->bchan);
1369+
if (IS_ERR(uc->bchan)) {
1370+
ret = PTR_ERR(uc->bchan);
1371+
uc->bchan = NULL;
1372+
return ret;
1373+
}
13701374

13711375
uc->tchan = uc->bchan;
13721376

0 commit comments

Comments
 (0)