Skip to contentSkip to conversation

dmaengine: cirrus: check that output may be truncated

PATCH Applied Alexander Sverdlin 2 participants 2 messages Sep 20, 2024 – Oct 11, 2024 dmaengine

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dmaengine: cirrus: check that output may be truncated

ep93xx_dma.c: In function 'ep93xx_dma_of_probe':
ep93xx_dma.c:1409:74: warning: '%u' directive output may be truncated

			       writing between 1 and 8 bytes into a region
			       of size 2 [-Wformat-truncation=]
		snprintf(dma_clk_name, sizeof(dma_clk_name), "m2p%u", i);
		                                                 ^~
Fixes d7333f9d3377 ("dmaengine: cirrus: use snprintf() to calm down gcc 13.3.0")
---
 drivers/dma/ep93xx_dma.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/dma/ep93xx_dma.c +5 -2
index 7989bc3db209..6b98a23e3332 100644
@@ -1391,6 +1391,7 @@ static struct ep93xx_dma_engine *ep93xx_dma_of_probe(struct platform_device *pde
 	INIT_LIST_HEAD(&dma_dev->channels);
 	for (i = 0; i < edma->num_channels; i++) {
 		struct ep93xx_dma_chan *edmac = &edma->channels[i];
+		int len;
 
 		edmac->chan.device = dma_dev;
 		edmac->regs = devm_platform_ioremap_resource(pdev, i);
@@ -1404,9 +1405,11 @@ static struct ep93xx_dma_engine *ep93xx_dma_of_probe(struct platform_device *pde
 		edmac->edma = edma;
 
 		if (edma->m2m)
-			snprintf(dma_clk_name, sizeof(dma_clk_name), "m2m%u", i);
+			len = snprintf(dma_clk_name, sizeof(dma_clk_name), "m2m%u", i);
 		else
-			snprintf(dma_clk_name, sizeof(dma_clk_name), "m2p%u", i);
+			len = snprintf(dma_clk_name, sizeof(dma_clk_name), "m2p%u", i);
+		if (len >= sizeof(dma_clk_name))
+			return ERR_PTR(-ENOBUFS);
 
 		edmac->clk = devm_clk_get(dev, dma_clk_name);
 		if (IS_ERR(edmac->clk)) {
Signature · 1 line
2.46.0
#1 lore raw
This patch was applied to soc/soc.git (arm/fixes) by Arnd Bergmann <[email protected]>:

Hello:

This patch was applied to soc/soc.git (arm/fixes)
by Arnd Bergmann <[email protected]>:

Quoted 8 lines · On Sat, 21 Sep 2024 01:21:55 +0200 you wrote:

ep93xx_dma.c: In function 'ep93xx_dma_of_probe':
ep93xx_dma.c:1409:74: warning: '%u' directive output may be truncated

			       writing between 1 and 8 bytes into a region
			       of size 2 [-Wformat-truncation=]
		snprintf(dma_clk_name, sizeof(dma_clk_name), "m2p%u", i);
		                                                 ^~

[...]

Here is the summary with links:
- dmaengine: cirrus: check that output may be truncated

    https://git.kernel.org/soc/soc/c/26d77ce57479

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html