[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20250930114500.103860-1-Pavel.Zhigulin@kaspersky.com>
Date: Tue, 30 Sep 2025 14:44:58 +0300
From: Pavel Zhigulin <Pavel.Zhigulin@...persky.com>
To: Peter Ujfalusi <peter.ujfalusi@...il.com>
CC: Pavel Zhigulin <Pavel.Zhigulin@...persky.com>, Vinod Koul
<vkoul@...nel.org>, Grygorii Strashko <grygorii.strashko@...com>, "open
list:TEXAS INSTRUMENTS DMA DRIVERS" <dmaengine@...r.kernel.org>, open list
<linux-kernel@...r.kernel.org>, <lvc-project@...uxtesting.org>
Subject:
Date: Tue, 30 Sep 2025 14:33:50 +0300
Subject: [PATCH] dma: k3-udma - fix potential null dereference in
k3_udma_glue_request_rx_chn_priv()
In k3_udma_glue_request_rx_chn_priv(), the pointer rx_chn->flows is
compared to NULL, but then passed to k3_udma_glue_release_rx_chn().
There it is dereferenced unconditionally after being passed to
k3_udma_glue_release_rx_flow() in a for loop. This happens because
rx_chn->flow_num is set before successful allocation.
This patch sets rx_chn->flow_num only after rx_chn->flows is
successfully allocated, which prevents the for loop from running if
allocation fails.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: d70241913413 ("dmaengine: ti: k3-udma: Add glue layer for non DMAengine users")
Signed-off-by: Pavel Zhigulin <Pavel.Zhigulin@...persky.com>
---
drivers/dma/ti/k3-udma-glue.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/dma/ti/k3-udma-glue.c b/drivers/dma/ti/k3-udma-glue.c
index f87d244cc2d6..221be7f00794 100644
--- a/drivers/dma/ti/k3-udma-glue.c
+++ b/drivers/dma/ti/k3-udma-glue.c
@@ -1031,8 +1031,6 @@ k3_udma_glue_request_rx_chn_priv(struct device *dev, const char *name,
rx_chn->flow_id_base = rx_chn->udma_rchan_id;
}
- rx_chn->flow_num = cfg->flow_id_num;
-
rx_chn->flows = devm_kcalloc(dev, rx_chn->flow_num,
sizeof(*rx_chn->flows), GFP_KERNEL);
if (!rx_chn->flows) {
@@ -1040,6 +1038,8 @@ k3_udma_glue_request_rx_chn_priv(struct device *dev, const char *name,
goto err;
}
+ rx_chn->flow_num = cfg->flow_id_num;
+
ret = k3_udma_glue_allocate_rx_flows(rx_chn, cfg);
if (ret)
goto err;
--
2.43.0
Powered by blists - more mailing lists