Skip to contentSkip to conversation

thermal: Replace sprintf() with sysfs_emit() for sysfs attrs

PATCH New Kaushlendra Kumar 1 participant 1 message Oct 30, 2025 Thermal

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 thermal: Replace sprintf() with sysfs_emit() for sysfs attrs

Replace sprintf() calls with sysfs_emit() in sysfs show functions to follow current kernel coding standards. sysfs_emit() is the preferred method for formatting sysfs output as it provides better bounds checking and is more secure.

---
 drivers/thermal/intel/int340x_thermal/int3400_thermal.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/thermal/intel/int340x_thermal/int3400_thermal.c +4 -4
index 908cc1bf57f1..82361ed7bda9 100644
@@ -112,7 +112,7 @@ static ssize_t available_uuids_show(struct device *dev,
 	int length = 0;
 
 	if (!priv->uuid_bitmap)
-		return sprintf(buf, "UNKNOWN\n");
+		return sysfs_emit(buf, "UNKNOWN\n");
 
 	for (i = 0; i < INT3400_THERMAL_MAXIMUM_UUID; i++) {
 		if (priv->uuid_bitmap & (1 << i))
@@ -129,7 +129,7 @@ static ssize_t current_uuid_show(struct device *dev,
 	int i, length = 0;
 
 	if (priv->current_uuid_index >= 0)
-		return sprintf(buf, "%s\n",
+		return sysfs_emit(buf, "%s\n",
 			       int3400_thermal_uuids[priv->current_uuid_index]);
 
 	for (i = 0; i <= INT3400_THERMAL_CRITICAL; i++) {
@@ -140,7 +140,7 @@ static ssize_t current_uuid_show(struct device *dev,
 	if (length)
 		return length;
 
-	return sprintf(buf, "INVALID\n");
+	return sysfs_emit(buf, "INVALID\n");
 }
 
 static int int3400_thermal_run_osc(acpi_handle handle, char *uuid_str, int *enable)
@@ -340,7 +340,7 @@ static ssize_t odvp_show(struct device *dev, struct device_attribute *attr,
 
 	odvp_attr = container_of(attr, struct odvp_attr, attr);
 
-	return sprintf(buf, "%d\n", odvp_attr->priv->odvp[odvp_attr->odvp]);
+	return sysfs_emit(buf, "%d\n", odvp_attr->priv->odvp[odvp_attr->odvp]);
 }
 
 static void cleanup_odvp(struct int3400_thermal_priv *priv)
Signature · 1 line
2.34.1