Skip to contentSkip to conversation

thermal: hwmon: replace deprecated strcpy() with strscpy()

PATCH Applied Osama Abdelkader 3 participants 3 messages Sep 3, 2025 – Sep 5, 2025 Thermal

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 thermal: hwmon: replace deprecated strcpy() with strscpy()

strcpy() is deprecated, use strscpy() instead for consistency with thermal subsystem since this is the only strcpy there.

---
v2:
Improve the commit msg: add that this is the only strcpy left in thermal subsystem

---
 drivers/thermal/thermal_hwmon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/thermal_hwmon.c +1 -1
index 0ecccd4d8556..64cc3ab949fe 100644
@@ -96,7 +96,7 @@ thermal_hwmon_lookup_by_type(const struct thermal_zone_device *tz)
 
 	mutex_lock(&thermal_hwmon_list_lock);
 	list_for_each_entry(hwmon, &thermal_hwmon_list, node) {
-		strcpy(type, tz->type);
+		strscpy(type, tz->type);
 		strreplace(type, '-', '_');
 		if (!strcmp(hwmon->type, type)) {
 			mutex_unlock(&thermal_hwmon_list_lock);
Signature · 1 line
2.43.0
reviewer Reviewed-by on v2 1/1
#1 lore raw
Quoted 16 lines · Osama Abdelkader

strcpy() is deprecated, use strscpy() instead for consistency with thermal subsystem since this is the only strcpy there.

---
v2:
Improve the commit msg: add that this is the only strcpy left in thermal subsystem

---
  drivers/thermal/thermal_hwmon.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/thermal_hwmon.c +0 -0
index 0ecccd4d8556..64cc3ab949fe 100644

drivers/thermal/thermal_hwmon.c thermal_hwmon_lookup_by_type(const struct thermal_zone_device *tz) · line 102

Quoted 8 lines
drivers/thermal/thermal_hwmon.c +1 -1
@@ -96,7 +96,7 @@ thermal_hwmon_lookup_by_type(const struct thermal_zone_device *tz)
 
  	mutex_lock(&thermal_hwmon_list_lock);
  	list_for_each_entry(hwmon, &thermal_hwmon_list, node) {
-		strcpy(type, tz->type);
+		strscpy(type, tz->type);
  		strreplace(type, '-', '_');
  		if (!strcmp(hwmon->type, type)) {
  			mutex_unlock(&thermal_hwmon_list_lock);

LGTM, that was indeed the single occurrence in thermal sub-system. Thanks!

maintainer Applied
#2 lore raw
Quoted 33 lines · Lukasz Luba
Quoted 16 lines · Osama Abdelkader

strcpy() is deprecated, use strscpy() instead for consistency with thermal subsystem since this is the only strcpy there.

---
v2:
Improve the commit msg: add that this is the only strcpy left in thermal subsystem

---
  drivers/thermal/thermal_hwmon.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/thermal_hwmon.c +0 -0
index 0ecccd4d8556..64cc3ab949fe 100644

drivers/thermal/thermal_hwmon.c thermal_hwmon_lookup_by_type(const struct thermal_zone_device *tz) · line 102

Quoted 8 lines
drivers/thermal/thermal_hwmon.c +1 -1
@@ -96,7 +96,7 @@ thermal_hwmon_lookup_by_type(const struct thermal_zone_device *tz)
 
      mutex_lock(&thermal_hwmon_list_lock);
      list_for_each_entry(hwmon, &thermal_hwmon_list, node) {
-             strcpy(type, tz->type);
+             strscpy(type, tz->type);
              strreplace(type, '-', '_');
              if (!strcmp(hwmon->type, type)) {
                      mutex_unlock(&thermal_hwmon_list_lock);

LGTM, that was indeed the single occurrence in thermal sub-system. Thanks!

Quoted 1 line

Applied as 6.18 material, thanks!