]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
dmaengine: avoid non-constant format string
authorArnd Bergmann <arnd@arndb.de>
Fri, 19 Jul 2024 10:23:12 +0000 (12:23 +0200)
committerVinod Koul <vkoul@kernel.org>
Thu, 29 Aug 2024 17:19:53 +0000 (22:49 +0530)
Using an arbitrary string as a printf-style format can be a security
problem if that string contains % characters, as the optionalal
-Wformat-security flag points out:

drivers/dma/dmaengine.c: In function '__dma_async_device_channel_register':
drivers/dma/dmaengine.c:1073:17: error: format not a string literal and no format arguments [-Werror=format-security]
 1073 |                 dev_set_name(&chan->dev->device, name);
      |                 ^~~~~~~~~~~~

Change this newly added instance to use "%s" as the format instead to
pass the actual name.

Fixes: 10b8e0fd3f72 ("dmaengine: add channel device name to channel registration")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Link: https://lore.kernel.org/r/20240719102319.546622-1-arnd@kernel.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/dma/dmaengine.c

index c380a4dda77a045ed768c929f1a0e1fea1fe8e91..c1357d7f3dc6ca7899c4d68a039567e73b0f089d 100644 (file)
@@ -1070,7 +1070,7 @@ static int __dma_async_device_channel_register(struct dma_device *device,
        if (!name)
                dev_set_name(&chan->dev->device, "dma%dchan%d", device->dev_id, chan->chan_id);
        else
-               dev_set_name(&chan->dev->device, name);
+               dev_set_name(&chan->dev->device, "%s", name);
        rc = device_register(&chan->dev->device);
        if (rc)
                goto err_out_ida;