Skip to contentSkip to conversation

platform/x86: think-lmi: Use sysfs_emit() in pending_reboot_show()

PATCH In review Thorsten Blum 3 participants 3 messages Sep 20 – Oct 5

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

PATCH 1/1 platform/x86: think-lmi: Use sysfs_emit() in pending_reboot_show()

Replace sprintf() with sysfs_emit() in pending_reboot_show(). sysfs_emit() is preferred for formatting sysfs output because it provides safer bounds checking.

---
 drivers/platform/x86/lenovo/think-lmi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/lenovo/think-lmi.c +1 -1
index 3ddc1f5cec19..7b319601662a 100644
@@ -1281,7 +1281,7 @@ static const struct kobj_type tlmi_pwd_setting_ktype = {
 static ssize_t pending_reboot_show(struct kobject *kobj, struct kobj_attribute *attr,
 				   char *buf)
 {
-	return sprintf(buf, "%d\n", tlmi_priv.pending_changes);
+	return sysfs_emit(buf, "%d\n", tlmi_priv.pending_changes);
 }
 
 static struct kobj_attribute pending_reboot = __ATTR_RO(pending_reboot);
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 24 lines · Thorsten Blum

Replace sprintf() with sysfs_emit() in pending_reboot_show(). sysfs_emit() is preferred for formatting sysfs output because it provides safer bounds checking.

---
 drivers/platform/x86/lenovo/think-lmi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/lenovo/think-lmi.c +1 -1
index 3ddc1f5cec19..7b319601662a 100644
@@ -1281,7 +1281,7 @@ static const struct kobj_type 
 tlmi_pwd_setting_ktype = {
 static ssize_t pending_reboot_show(struct kobject *kobj, struct 
 kobj_attribute *attr,
 				   char *buf)
 {
-	return sprintf(buf, "%d\n", tlmi_priv.pending_changes);
+	return sysfs_emit(buf, "%d\n", tlmi_priv.pending_changes);
 }
Quoted 1 line

static struct kobj_attribute pending_reboot = __ATTR_RO(pending_reboot);

Mark

maintainer
#2 lore raw
In reply to Thorsten Blum
Quoted 3 lines · Thorsten Blum

Replace sprintf() with sysfs_emit() in pending_reboot_show(). sysfs_emit() is preferred for formatting sysfs output because it provides safer bounds checking.

Thank you for your contribution, it has been applied to my local review-ilpo-next branch. Note it will show up in the public platform-drivers-x86/review-ilpo-next branch only once I've pushed my local branch there, which might take a while.

FYI [if applicable to your patch], as per Linus' policy change, also fixes are mostly routed through for-next unless the fix is for a commit introduced in the most recent cycle or is clearly a regression fix.

The list of commits applied:
[1/1] platform/x86: think-lmi: Use sysfs_emit() in pending_reboot_show()

      commit: 6cbf338f2e442f2843c208da92f049e7e23b5e5f

--
i.