[lvc-project] (no subject)

Pavel Zhigulin Pavel.Zhigulin at kaspersky.com
Tue Sep 30 14:44:58 MSK 2025


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 at kaspersky.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




More information about the lvc-project mailing list