Skip to contentSkip to conversation

EDAC: fix dev_set_name() format string

PATCH Applied Arnd Bergmann 2 participants 2 messages Mar 4, 2025 – Mar 5, 2025 EDAC-core

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 EDAC: fix dev_set_name() format string

From: Arnd Bergmann <[email protected]>

Passing a variable string as the format to dev_set_name() causes a W=1 warning:

drivers/edac/edac_device.c:736:9: error: format not a string literal and no format arguments [-Werror=format-security]

  736 |         ret = dev_set_name(&ctx->dev, name);
      |         ^~~

Use a literal "%s" instead so the name can be the argument.

Fixes db99ea5f2c03 ("EDAC: Add support for EDAC device features control")
---
 drivers/edac/edac_device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/edac/edac_device.c +1 -1
index 16611515ab34..0734909b08a4 100644
@@ -733,7 +733,7 @@ int edac_dev_register(struct device *parent, char *name,
 	ctx->private = private;
 	dev_set_drvdata(&ctx->dev, ctx);
 
-	ret = dev_set_name(&ctx->dev, name);
+	ret = dev_set_name(&ctx->dev, "%s", name);
 	if (ret)
 		goto data_mem_free;
 
Signature · 1 line
2.39.5
maintainer Applied
#1 lore raw
Quoted 8 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

Passing a variable string as the format to dev_set_name() causes a W=1 warning:

drivers/edac/edac_device.c:736:9: error: format not a string literal and no format arguments [-Werror=format-security]

  736 |         ret = dev_set_name(&ctx->dev, name);
      |         ^~~
Quoted 7 lines

Use a literal "%s" instead so the name can be the argument.

Fixes db99ea5f2c03 ("EDAC: Add support for EDAC device features control")
---
 drivers/edac/edac_device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied, thanks.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette