]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
power: reset: reboot-mode: fix -Wformat-security warning
authorArnd Bergmann <arnd@arndb.de>
Fri, 6 Mar 2026 15:07:34 +0000 (16:07 +0100)
committerSebastian Reichel <sebastian.reichel@collabora.com>
Wed, 11 Mar 2026 06:58:43 +0000 (07:58 +0100)
The device_create() function expects a format string to construct a device
name, so passing a variable here introduces a possible vulnerability in
case the string can contain '%' characters:

drivers/power/reset/reboot-mode.c:148:22: error: format string is not a string literal (potentially insecure) [-Werror,-Wformat-security]
drivers/power/reset/reboot-mode.c:148:22: note: treat the string as an argument to avoid this
  148 |                                                  (void *)priv, reboot->dev->driver->name);

Use an trivial "%s" format instead and pass the name as the string to be
included here.

Fixes: cfaf0a90789a ("power: reset: reboot-mode: Expose sysfs for registered reboot_modes")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Link: https://patch.msgid.link/20260306150738.497978-1-arnd@kernel.org
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
drivers/power/reset/reboot-mode.c

index ad239e96774b6f033f2bdea9e4779403bc609c57..d20e44db053256d87ad8034ddab233e49d36072d 100644 (file)
@@ -145,7 +145,8 @@ static int reboot_mode_create_device(struct reboot_mode_driver *reboot)
        }
 
        priv->reboot_mode_device = device_create(&reboot_mode_class, NULL, 0,
-                                                (void *)priv, reboot->dev->driver->name);
+                                                (void *)priv, "%s",
+                                                reboot->dev->driver->name);
        if (IS_ERR(priv->reboot_mode_device)) {
                ret = PTR_ERR(priv->reboot_mode_device);
                goto error;