]> Git Repo - linux.git/commitdiff
dmaengine: loongson1-apb-dma: Fix the build warning caused by the size of pdev_irqname
authorKeguang Zhang <[email protected]>
Sat, 31 Aug 2024 09:41:09 +0000 (17:41 +0800)
committerVinod Koul <[email protected]>
Mon, 2 Sep 2024 08:26:32 +0000 (13:56 +0530)
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]>
drivers/dma/loongson1-apb-dma.c

index ca43c67a82036622c08ec8d829288c1de9fb712c..255fe7eca212a9a628dbed7dce21bead04b0ae23 100644 (file)
@@ -526,9 +526,9 @@ static int ls1x_dma_chan_probe(struct platform_device *pdev,
 
        for (id = 0; id < dma->nr_chans; id++) {
                struct ls1x_dma_chan *chan = &dma->chan[id];
-               char pdev_irqname[4];
+               char pdev_irqname[16];
 
-               sprintf(pdev_irqname, "ch%d", id);
+               snprintf(pdev_irqname, sizeof(pdev_irqname), "ch%d", id);
                chan->irq = platform_get_irq_byname(pdev, pdev_irqname);
                if (chan->irq < 0)
                        return dev_err_probe(&pdev->dev, chan->irq,
This page took 0.066569 seconds and 4 git commands to generate.