[PATCH 2/6] dma-devices: k3-udma: use snprintf instead of sprintf

Jules Maselbas jmaselbas at zdiv.net
Fri Mar 14 03:40:30 PDT 2025


Replace the use of sprintf by snprintf, in this case sprintf could not
overflow because the size of uc::name is well chosen to be able to fit
the largest u32 integer.

Signed-off-by: Jules Maselbas <jmaselbas at zdiv.net>
---
 drivers/dma/ti/k3-udma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/dma/ti/k3-udma.c b/drivers/dma/ti/k3-udma.c
index 8f46364145..d32ed46b0f 100644
--- a/drivers/dma/ti/k3-udma.c
+++ b/drivers/dma/ti/k3-udma.c
@@ -2678,7 +2678,7 @@ static int k3_udma_probe(struct device *dev)
 		uc->config.mapped_channel_id = -1;
 		uc->config.default_flow_id = -1;
 		uc->config.dir = DMA_MEM_TO_MEM;
-		sprintf(uc->name, "UDMA chan%d\n", i);
+		snprintf(uc->name, sizeof(uc->name), "UDMA chan%d\n", i);
 		if (!i)
 			uc->in_use = true;
 	}
-- 
2.48.1




More information about the barebox mailing list