Linux Power Management development
 help / color / mirror / Atom feed
* [PATCH v1 1/1] thermal: sysfs: switch to use scnprintf() to suppress truncation warning
@ 2026-08-17 10:33 Andy Shevchenko
  2026-09-03 11:41 ` Andy Shevchenko
  2026-09-04  8:01 ` Lukasz Luba
  0 siblings, 2 replies; 4+ messages in thread
From: Andy Shevchenko @ 2026-08-17 10:33 UTC (permalink / raw)
  To: linux-pm, linux-kernel
  Cc: Rafael J. Wysocki, Daniel Lezcano, Zhang Rui, Lukasz Luba,
	Andy Shevchenko

Switch the sysfs code to use scnprintf() to avoid warnings about potential
truncation of the names of the sysfs attributes. We can't increase the buffer
size because the size is the part of an ABI for some reason. Note, with
the current size of buffer the affected attributes have a room for up to
1000 names, which ought to be enough for all cases. There is no functional
change, as the same limitation was implied before.

Fixes: c56f5c0342df ("Thermal: Make Thermal trip points writeable")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/thermal/thermal_sysfs.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c
index b44abfc997ed..44bd7c50e4ac 100644
--- a/drivers/thermal/thermal_sysfs.c
+++ b/drivers/thermal/thermal_sysfs.c
@@ -400,8 +400,8 @@ static int create_trip_attrs(struct thermal_zone_device *tz)
 		struct thermal_trip_attrs *trip_attrs = &td->trip_attrs;
 
 		/* create trip type attribute */
-		snprintf(trip_attrs->type.name, THERMAL_NAME_LENGTH,
-			 "trip_point_%d_type", i);
+		scnprintf(trip_attrs->type.name, sizeof(trip_attrs->type.name),
+			  "trip_point_%d_type", i);
 
 		sysfs_attr_init(&trip_attrs->type.attr.attr);
 		trip_attrs->type.attr.attr.name = trip_attrs->type.name;
@@ -410,8 +410,8 @@ static int create_trip_attrs(struct thermal_zone_device *tz)
 		attrs[i] = &trip_attrs->type.attr.attr;
 
 		/* create trip temp attribute */
-		snprintf(trip_attrs->temp.name, THERMAL_NAME_LENGTH,
-			 "trip_point_%d_temp", i);
+		scnprintf(trip_attrs->temp.name, sizeof(trip_attrs->temp.name),
+			  "trip_point_%d_temp", i);
 
 		sysfs_attr_init(&trip_attrs->temp.attr.attr);
 		trip_attrs->temp.attr.attr.name = trip_attrs->temp.name;
@@ -423,8 +423,8 @@ static int create_trip_attrs(struct thermal_zone_device *tz)
 		}
 		attrs[i + tz->num_trips] = &trip_attrs->temp.attr.attr;
 
-		snprintf(trip_attrs->hyst.name, THERMAL_NAME_LENGTH,
-			 "trip_point_%d_hyst", i);
+		scnprintf(trip_attrs->hyst.name, sizeof(trip_attrs->hyst.name),
+			  "trip_point_%d_hyst", i);
 
 		sysfs_attr_init(&trip_attrs->hyst.attr.attr);
 		trip_attrs->hyst.attr.attr.name = trip_attrs->hyst.name;
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v1 1/1] thermal: sysfs: switch to use scnprintf() to suppress truncation warning
  2026-08-17 10:33 [PATCH v1 1/1] thermal: sysfs: switch to use scnprintf() to suppress truncation warning Andy Shevchenko
@ 2026-09-03 11:41 ` Andy Shevchenko
  2026-09-04  8:01 ` Lukasz Luba
  1 sibling, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2026-09-03 11:41 UTC (permalink / raw)
  To: linux-pm, linux-kernel
  Cc: Rafael J. Wysocki, Daniel Lezcano, Zhang Rui, Lukasz Luba

On Mon, Aug 17, 2026 at 12:33:24PM +0200, Andy Shevchenko wrote:
> Switch the sysfs code to use scnprintf() to avoid warnings about potential
> truncation of the names of the sysfs attributes. We can't increase the buffer
> size because the size is the part of an ABI for some reason. Note, with
> the current size of buffer the affected attributes have a room for up to
> 1000 names, which ought to be enough for all cases. There is no functional
> change, as the same limitation was implied before.

I still have the build issues, can we get this applied to v7.3-rcX, please?

> Fixes: c56f5c0342df ("Thermal: Make Thermal trip points writeable")

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v1 1/1] thermal: sysfs: switch to use scnprintf() to suppress truncation warning
  2026-08-17 10:33 [PATCH v1 1/1] thermal: sysfs: switch to use scnprintf() to suppress truncation warning Andy Shevchenko
  2026-09-03 11:41 ` Andy Shevchenko
@ 2026-09-04  8:01 ` Lukasz Luba
  2026-09-04 13:54   ` Rafael J. Wysocki (Intel)
  1 sibling, 1 reply; 4+ messages in thread
From: Lukasz Luba @ 2026-09-04  8:01 UTC (permalink / raw)
  To: Andy Shevchenko, linux-pm, linux-kernel
  Cc: Rafael J. Wysocki, Daniel Lezcano, Zhang Rui



On 8/17/26 11:33, Andy Shevchenko wrote:
> Switch the sysfs code to use scnprintf() to avoid warnings about potential
> truncation of the names of the sysfs attributes. We can't increase the buffer
> size because the size is the part of an ABI for some reason. Note, with
> the current size of buffer the affected attributes have a room for up to
> 1000 names, which ought to be enough for all cases. There is no functional
> change, as the same limitation was implied before.

Right, it doesn't touch the real truncation check problem only avoids
the complain from the tool. We can think about this later in some
redesign.

> 
> Fixes: c56f5c0342df ("Thermal: Make Thermal trip points writeable")
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>   drivers/thermal/thermal_sysfs.c | 12 ++++++------
>   1 file changed, 6 insertions(+), 6 deletions(-)


Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v1 1/1] thermal: sysfs: switch to use scnprintf() to suppress truncation warning
  2026-09-04  8:01 ` Lukasz Luba
@ 2026-09-04 13:54   ` Rafael J. Wysocki (Intel)
  0 siblings, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki (Intel) @ 2026-09-04 13:54 UTC (permalink / raw)
  To: Lukasz Luba, Andy Shevchenko
  Cc: linux-pm, linux-kernel, Rafael J. Wysocki, Daniel Lezcano,
	Zhang Rui

On Fri, Sep 4, 2026 at 10:01 AM Lukasz Luba <lukasz.luba@arm.com> wrote:
>
>
>
> On 8/17/26 11:33, Andy Shevchenko wrote:
> > Switch the sysfs code to use scnprintf() to avoid warnings about potential
> > truncation of the names of the sysfs attributes. We can't increase the buffer
> > size because the size is the part of an ABI for some reason. Note, with
> > the current size of buffer the affected attributes have a room for up to
> > 1000 names, which ought to be enough for all cases. There is no functional
> > change, as the same limitation was implied before.
>
> Right, it doesn't touch the real truncation check problem only avoids
> the complain from the tool. We can think about this later in some
> redesign.
>
> >
> > Fixes: c56f5c0342df ("Thermal: Make Thermal trip points writeable")
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > ---
> >   drivers/thermal/thermal_sysfs.c | 12 ++++++------
> >   1 file changed, 6 insertions(+), 6 deletions(-)
>
>
> Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>

Applied and added to linux-pm.git/fixes, thanks!

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-09-04 13:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-17 10:33 [PATCH v1 1/1] thermal: sysfs: switch to use scnprintf() to suppress truncation warning Andy Shevchenko
2026-09-03 11:41 ` Andy Shevchenko
2026-09-04  8:01 ` Lukasz Luba
2026-09-04 13:54   ` Rafael J. Wysocki (Intel)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox