Skip to contentSkip to conversation

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

PATCH Superseded Osama Abdelkader 2 participants 7 messages Sep 1, 2025 – Sep 3, 2025 Thermal

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

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

strcpy() is deprecated; use strscpy() instead.

---
 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
#1 lore raw
Quoted 2 lines · Osama Abdelkader

strcpy() is deprecated; use strscpy() instead.

So why is it better to use strscpy() in this particular case?

Quoted 21 lines
---
 drivers/thermal/thermal_hwmon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/thermal_hwmon.c +1 -2
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);
--

2.43.0

#2 lore raw
Quoted 6 lines · Rafael J. Wysocki
Quoted 2 lines · Osama Abdelkader

strcpy() is deprecated; use strscpy() instead.

So why is it better to use strscpy() in this particular case?

Thanks for the review. Technically, there is no change since both have const buf size, it's just for consistency with other drivers.

Regards,
Osama

Quoted 22 lines
Quoted 22 lines
---
 drivers/thermal/thermal_hwmon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/thermal_hwmon.c +1 -2
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);
--

2.43.0

#3 lore raw
Quoted 11 lines · Osama Abdelkader
Quoted 6 lines · Rafael J. Wysocki
Quoted 2 lines · Osama Abdelkader

strcpy() is deprecated; use strscpy() instead.

So why is it better to use strscpy() in this particular case?

Thanks for the review. Technically, there is no change since both have const buf size, it's just for consistency with other drivers.

$ cd linux-kernel-source
$ git grep strcpy | wc -l
1187

What kind of consistency do you mean?

#4 lore raw
Quoted 11 lines · Rafael J. Wysocki
Quoted 9 lines · Osama Abdelkader
Quoted 6 lines · Rafael J. Wysocki
Quoted 2 lines · Osama Abdelkader

strcpy() is deprecated; use strscpy() instead.

So why is it better to use strscpy() in this particular case?

Quoted 8 lines
Quoted 2 lines

Thanks for the review. Technically, there is no change since both have const buf size, it's just for consistency with other drivers.

$ cd linux-kernel-source
$ git grep strcpy | wc -l
1187

What kind of consistency do you mean?

I mean in thermal subsystem, it's only this one.

#5 lore raw
Quoted 16 lines · Osama Abdelkader
Quoted 14 lines · Rafael J. Wysocki
Quoted 11 lines · Osama Abdelkader
Quoted 6 lines · Rafael J. Wysocki
Quoted 2 lines · Osama Abdelkader

strcpy() is deprecated; use strscpy() instead.

So why is it better to use strscpy() in this particular case?

Thanks for the review. Technically, there is no change since both have const buf size, it's just for consistency with other drivers.

Quoted 7 lines
Quoted 5 lines
$ cd linux-kernel-source
$ git grep strcpy | wc -l
1187

What kind of consistency do you mean?

I mean in thermal subsystem, it's only this one.

So please add this information to the patch changelog.

#6 lore raw
Quoted 22 lines · Rafael J. Wysocki
Quoted 20 lines · Osama Abdelkader
Quoted 18 lines · Rafael J. Wysocki
Quoted 11 lines · Osama Abdelkader
Quoted 6 lines · Rafael J. Wysocki
Quoted 2 lines · Osama Abdelkader

strcpy() is deprecated; use strscpy() instead.

So why is it better to use strscpy() in this particular case?

Thanks for the review. Technically, there is no change since both have const buf size, it's just for consistency with other drivers.

$ cd linux-kernel-source
$ git grep strcpy | wc -l
1187
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

What kind of consistency do you mean?

I mean in thermal subsystem, it's only this one.

So please add this information to the patch changelog.

Sure, I just sent v2.

Thanks,
Osama