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

Thorsten Blum posted 1 patch 5 days, 13 hours ago
drivers/platform/x86/lenovo/think-lmi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] platform/x86: think-lmi: Use sysfs_emit() in pending_reboot_show()
Posted by Thorsten Blum 5 days, 13 hours ago
Replace sprintf() with sysfs_emit() in pending_reboot_show().
sysfs_emit() is preferred for formatting sysfs output because it
provides safer bounds checking.

Signed-off-by: Thorsten Blum <blum@kernel.org>
---
 drivers/platform/x86/lenovo/think-lmi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/platform/x86/lenovo/think-lmi.c b/drivers/platform/x86/lenovo/think-lmi.c
index 3ddc1f5cec19..7b319601662a 100644
--- a/drivers/platform/x86/lenovo/think-lmi.c
+++ b/drivers/platform/x86/lenovo/think-lmi.c
@@ -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);
Re: [PATCH] platform/x86: think-lmi: Use sysfs_emit() in pending_reboot_show()
Posted by Mark Pearson 3 days, 6 hours ago
On Sun, Sep 20, 2026, at 6:35 AM, Thorsten Blum wrote:
> Replace sprintf() with sysfs_emit() in pending_reboot_show().
> sysfs_emit() is preferred for formatting sysfs output because it
> provides safer bounds checking.
>
> Signed-off-by: Thorsten Blum <blum@kernel.org>
> ---
>  drivers/platform/x86/lenovo/think-lmi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/platform/x86/lenovo/think-lmi.c 
> b/drivers/platform/x86/lenovo/think-lmi.c
> index 3ddc1f5cec19..7b319601662a 100644
> --- a/drivers/platform/x86/lenovo/think-lmi.c
> +++ b/drivers/platform/x86/lenovo/think-lmi.c
> @@ -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);

Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Mark