Skip to contentSkip to conversation

iommu: vsi: avoid -Wformat-security warning

PATCH Applied Arnd Bergmann 3 participants 3 messages May 19 – May 28

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iommu: vsi: avoid -Wformat-security warning

From: Arnd Bergmann <[email protected]>

When -Wformat-security is enabled, it catches a call to iommu_device_sysfs_add() that passes a string variable in place of a format:

drivers/iommu/vsi-iommu.c: In function 'vsi_iommu_probe':
drivers/iommu/vsi-iommu.c:717:9: error: format not a string literal and no format arguments [-Werror=format-security]

  717 |         err = iommu_device_sysfs_add(&iommu->iommu, dev, NULL, dev_name(dev));
      |         ^~~

Pass this indirectly using "%s" as the format instead.

Fixes 917ace84b770 ("iommu: Add verisilicon IOMMU driver")
---
 drivers/iommu/vsi-iommu.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iommu/vsi-iommu.c +2 -1
index 5d0721bd2c7a..23913720d484 100644
@@ -714,7 +714,8 @@ static int vsi_iommu_probe(struct platform_device *pdev)
 	pm_runtime_use_autosuspend(dev);
 	pm_runtime_enable(dev);
 
-	err = iommu_device_sysfs_add(&iommu->iommu, dev, NULL, dev_name(dev));
+	err = iommu_device_sysfs_add(&iommu->iommu, dev, NULL, "%s",
+				     dev_name(dev));
 	if (err)
 		goto err_runtime_disable;
 
Signature · 1 line
2.39.5
maintainer Reviewed-by on v1 1/1
#1 lore raw

Le 19/05/2026 à 22:36, Arnd Bergmann a écrit :

Quoted 8 lines

From: Arnd Bergmann <[email protected]>

When -Wformat-security is enabled, it catches a call to iommu_device_sysfs_add() that passes a string variable in place of a format:

drivers/iommu/vsi-iommu.c: In function 'vsi_iommu_probe':
drivers/iommu/vsi-iommu.c:717:9: error: format not a string literal and no format arguments [-Werror=format-security]

Quoted 7 lines
   717 |         err = iommu_device_sysfs_add(&iommu->iommu, dev, NULL, dev_name(dev));
       |         ^~~

Pass this indirectly using "%s" as the format instead.

Fixes 917ace84b770 ("iommu: Add verisilicon IOMMU driver")
Quoted 18 lines
---
  drivers/iommu/vsi-iommu.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iommu/vsi-iommu.c +2 -1
index 5d0721bd2c7a..23913720d484 100644
@@ -714,7 +714,8 @@ static int vsi_iommu_probe(struct platform_device *pdev)
  	pm_runtime_use_autosuspend(dev);
  	pm_runtime_enable(dev);
 
-	err = iommu_device_sysfs_add(&iommu->iommu, dev, NULL, dev_name(dev));
+	err = iommu_device_sysfs_add(&iommu->iommu, dev, NULL, "%s",
+				     dev_name(dev));
  	if (err)
  		goto err_runtime_disable;