]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
thermal: sysfs: Replace sscanf() with kstrtoul()
authorOvidiu Panait <ovidiu.panait.oss@gmail.com>
Sat, 6 Jun 2026 21:04:20 +0000 (00:04 +0300)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 8 Jun 2026 13:57:05 +0000 (15:57 +0200)
Replace sscanf() with kstrtoul() in cur_state_store(), as kstrto<type>
is preferred over single-variable sscanf().

Signed-off-by: Ovidiu Panait <ovidiu.panait.oss@gmail.com>
[ rjw: Changelog edits ]
Link: https://patch.msgid.link/20260606210420.2311145-3-ovidiu.panait.oss@gmail.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/thermal/thermal_sysfs.c

index 9f2f25a6da371513935a222b4ffd6f00df46b992..b44abfc997edf3a98197b50c7aa84d190123a87d 100644 (file)
@@ -536,11 +536,9 @@ cur_state_store(struct device *dev, struct device_attribute *attr,
        unsigned long state;
        int result;
 
-       if (sscanf(buf, "%ld\n", &state) != 1)
-               return -EINVAL;
-
-       if ((long)state < 0)
-               return -EINVAL;
+       result = kstrtoul(buf, 10, &state);
+       if (result < 0)
+               return result;
 
        /* Requested state should be less than max_state + 1 */
        if (state > cdev->max_state)