Skip to content

Commit e0bee4b

Browse files
kelvincheungvinodkoul
authored andcommitted
dmaengine: loongson1-apb-dma: Fix the build warning caused by the size of pdev_irqname
drivers/dma/loongson1-apb-dma.c: In function 'ls1x_dma_probe': drivers/dma/loongson1-apb-dma.c:531:42: warning: '%d' directive writing between 1 and 8 bytes into a region of size 2 [-Wformat-overflow=] 531 | sprintf(pdev_irqname, "ch%d", id); | ^~ In function 'ls1x_dma_chan_probe', inlined from 'ls1x_dma_probe' at drivers/dma/loongson1-apb-dma.c:605:8: drivers/dma/loongson1-apb-dma.c:531:39: note: directive argument in the range [0, 19522579] 531 | sprintf(pdev_irqname, "ch%d", id); | ^~~~~~ drivers/dma/loongson1-apb-dma.c:531:17: note: 'sprintf' output between 4 and 11 bytes into a destination of size 4 531 | sprintf(pdev_irqname, "ch%d", id); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Fix the array size and use snprintf() instead of sprintf(). Reported-by: kernel test robot <[email protected]> Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/ Signed-off-by: Keguang Zhang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent a688efe commit e0bee4b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/dma/loongson1-apb-dma.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,9 +526,9 @@ static int ls1x_dma_chan_probe(struct platform_device *pdev,
526526

527527
for (id = 0; id < dma->nr_chans; id++) {
528528
struct ls1x_dma_chan *chan = &dma->chan[id];
529-
char pdev_irqname[4];
529+
char pdev_irqname[16];
530530

531-
sprintf(pdev_irqname, "ch%d", id);
531+
snprintf(pdev_irqname, sizeof(pdev_irqname), "ch%d", id);
532532
chan->irq = platform_get_irq_byname(pdev, pdev_irqname);
533533
if (chan->irq < 0)
534534
return dev_err_probe(&pdev->dev, chan->irq,

0 commit comments

Comments
 (0)