[Intel-xe] [PATCH 3/3] drm/xe: Fix format string security warning

Michał Winiarski michal.winiarski at intel.com
Wed Oct 18 11:58:26 UTC 2023


While "gtidle->name" is not user-controllable string, it's still a bad
practice to pass variable as a format string, it also causes the build
to fail with:

drivers/gpu/drm/xe/xe_gt_idle_sysfs.c:88:26: error: format string is not a string literal (potentially insecure) [-Werror,-Wformat-security]

Signed-off-by: Michał Winiarski <michal.winiarski at intel.com>
---
 drivers/gpu/drm/xe/xe_gt_idle_sysfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/xe/xe_gt_idle_sysfs.c b/drivers/gpu/drm/xe/xe_gt_idle_sysfs.c
index 7238e96a116cf..8df9840811cda 100644
--- a/drivers/gpu/drm/xe/xe_gt_idle_sysfs.c
+++ b/drivers/gpu/drm/xe/xe_gt_idle_sysfs.c
@@ -85,7 +85,7 @@ static ssize_t name_show(struct device *dev,
 {
 	struct xe_gt_idle *gtidle = dev_to_gtidle(dev);
 
-	return sysfs_emit(buff, gtidle->name);
+	return sysfs_emit(buff, "%s\n", gtidle->name);
 }
 static DEVICE_ATTR_RO(name);
 
-- 
2.42.0



More information about the Intel-xe mailing list