summaryrefslogtreecommitdiff
path: root/drivers/thermal
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2026-06-11 18:21:22 +0200
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2026-06-11 18:21:22 +0200
commitbc1c872ce0ab3984f5fcefeb952541a802b891e7 (patch)
tree3a6c0a37f586b4be4e77d690177366f8efd6f302 /drivers/thermal
parent9e2d7e32da60e594c41b692305b206a3286ea505 (diff)
parent64762d48ec84d36fc2618920a731368387253efc (diff)
downloadlinux-next-bc1c872ce0ab3984f5fcefeb952541a802b891e7.tar.gz
linux-next-bc1c872ce0ab3984f5fcefeb952541a802b891e7.zip
Merge branch 'thermal-testing'
Merge thermal control testing facility updates for 7.2: - Replace sscanf() with kstrtoul() or kstrtoint() in several places in the thermal testing code (Ovidiu Panait) - Make the thermal testing facility reject missing command arguments to avoid NULL pointer dereferences (Samuel Moelius) * thermal-testing: thermal: sysfs: Replace sscanf() with kstrtoul() thermal: testing: Replace sscanf() with kstrtoint() thermal: testing: reject missing command arguments
Diffstat (limited to 'drivers/thermal')
-rw-r--r--drivers/thermal/testing/command.c12
-rw-r--r--drivers/thermal/testing/zone.c12
-rw-r--r--drivers/thermal/thermal_sysfs.c8
3 files changed, 21 insertions, 11 deletions
diff --git a/drivers/thermal/testing/command.c b/drivers/thermal/testing/command.c
index 1159ecea57e7..fbf7ab9729b5 100644
--- a/drivers/thermal/testing/command.c
+++ b/drivers/thermal/testing/command.c
@@ -116,18 +116,30 @@ static int tt_command_exec(int index, const char *arg)
break;
case TT_CMD_DELTZ:
+ if (!arg || !*arg)
+ return -EINVAL;
+
ret = tt_del_tz(arg);
break;
case TT_CMD_TZADDTRIP:
+ if (!arg || !*arg)
+ return -EINVAL;
+
ret = tt_zone_add_trip(arg);
break;
case TT_CMD_TZREG:
+ if (!arg || !*arg)
+ return -EINVAL;
+
ret = tt_zone_reg(arg);
break;
case TT_CMD_TZUNREG:
+ if (!arg || !*arg)
+ return -EINVAL;
+
ret = tt_zone_unreg(arg);
break;
diff --git a/drivers/thermal/testing/zone.c b/drivers/thermal/testing/zone.c
index 3c339242f52d..f7f9ca2f1f2c 100644
--- a/drivers/thermal/testing/zone.c
+++ b/drivers/thermal/testing/zone.c
@@ -239,9 +239,9 @@ int tt_del_tz(const char *arg)
int ret;
int id;
- ret = sscanf(arg, "%d", &id);
- if (ret != 1)
- return -EINVAL;
+ ret = kstrtoint(arg, 10, &id);
+ if (ret < 0)
+ return ret;
struct tt_work *tt_work __free(kfree) = kzalloc_obj(*tt_work);
if (!tt_work)
@@ -279,9 +279,9 @@ static struct tt_thermal_zone *tt_get_tt_zone(const char *arg)
struct tt_thermal_zone *tt_zone;
int ret, id;
- ret = sscanf(arg, "%d", &id);
- if (ret != 1)
- return ERR_PTR(-EINVAL);
+ ret = kstrtoint(arg, 10, &id);
+ if (ret < 0)
+ return ERR_PTR(ret);
guard(mutex)(&tt_thermal_zones_lock);
diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c
index 9f2f25a6da37..b44abfc997ed 100644
--- a/drivers/thermal/thermal_sysfs.c
+++ b/drivers/thermal/thermal_sysfs.c
@@ -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)