mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] thermal: core: Replace sprintf in thermal_bind_cdev_to_trip
@ 2026-02-23  7:32 Thorsten Blum
  2026-03-06 14:05 ` Lukasz Luba
  0 siblings, 1 reply; 3+ messages in thread
From: Thorsten Blum @ 2026-02-23  7:32 UTC (permalink / raw)
  To: Rafael J. Wysocki, Daniel Lezcano, Zhang Rui, Lukasz Luba
  Cc: Thorsten Blum, linux-pm, linux-kernel

Replace unbounded sprintf() with the safer snprintf(). While the
current code works correctly, snprintf() is safer and follows secure
coding best practices.  No functional changes.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 drivers/thermal/thermal_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 17ca5c082643..89dd1666805f 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -861,7 +861,7 @@ static int thermal_bind_cdev_to_trip(struct thermal_zone_device *tz,
 		goto free_mem;
 
 	dev->id = result;
-	sprintf(dev->name, "cdev%d", dev->id);
+	snprintf(dev->name, sizeof(dev->name), "cdev%d", dev->id);
 	result =
 	    sysfs_create_link(&tz->device.kobj, &cdev->device.kobj, dev->name);
 	if (result)
-- 
Thorsten Blum <thorsten.blum@linux.dev>
GPG: 1D60 735E 8AEF 3BE4 73B6  9D84 7336 78FD 8DFE EAD4


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

* Re: [PATCH] thermal: core: Replace sprintf in thermal_bind_cdev_to_trip
  2026-02-23  7:32 [PATCH] thermal: core: Replace sprintf in thermal_bind_cdev_to_trip Thorsten Blum
@ 2026-03-06 14:05 ` Lukasz Luba
  2026-03-06 17:49   ` Rafael J. Wysocki
  0 siblings, 1 reply; 3+ messages in thread
From: Lukasz Luba @ 2026-03-06 14:05 UTC (permalink / raw)
  To: Thorsten Blum
  Cc: linux-pm, linux-kernel, Daniel Lezcano, Rafael J. Wysocki, Zhang Rui



On 2/23/26 07:32, Thorsten Blum wrote:
> Replace unbounded sprintf() with the safer snprintf(). While the
> current code works correctly, snprintf() is safer and follows secure
> coding best practices.  No functional changes.

Agree

> 
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
>   drivers/thermal/thermal_core.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
> index 17ca5c082643..89dd1666805f 100644
> --- a/drivers/thermal/thermal_core.c
> +++ b/drivers/thermal/thermal_core.c
> @@ -861,7 +861,7 @@ static int thermal_bind_cdev_to_trip(struct thermal_zone_device *tz,
>   		goto free_mem;
>   
>   	dev->id = result;
> -	sprintf(dev->name, "cdev%d", dev->id);
> +	snprintf(dev->name, sizeof(dev->name), "cdev%d", dev->id);
>   	result =
>   	    sysfs_create_link(&tz->device.kobj, &cdev->device.kobj, dev->name);
>   	if (result)


LGTM, please add the tag and re-send so it's on top
so faster to pick-up for merging

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

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

* Re: [PATCH] thermal: core: Replace sprintf in thermal_bind_cdev_to_trip
  2026-03-06 14:05 ` Lukasz Luba
@ 2026-03-06 17:49   ` Rafael J. Wysocki
  0 siblings, 0 replies; 3+ messages in thread
From: Rafael J. Wysocki @ 2026-03-06 17:49 UTC (permalink / raw)
  To: Lukasz Luba, Thorsten Blum
  Cc: linux-pm, linux-kernel, Daniel Lezcano, Rafael J. Wysocki, Zhang Rui

On Fri, Mar 6, 2026 at 3:05 PM Lukasz Luba <lukasz.luba@arm.com> wrote:
>
>
>
> On 2/23/26 07:32, Thorsten Blum wrote:
> > Replace unbounded sprintf() with the safer snprintf(). While the
> > current code works correctly, snprintf() is safer and follows secure
> > coding best practices.  No functional changes.
>
> Agree
>
> >
> > Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> > ---
> >   drivers/thermal/thermal_core.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
> > index 17ca5c082643..89dd1666805f 100644
> > --- a/drivers/thermal/thermal_core.c
> > +++ b/drivers/thermal/thermal_core.c
> > @@ -861,7 +861,7 @@ static int thermal_bind_cdev_to_trip(struct thermal_zone_device *tz,
> >               goto free_mem;
> >
> >       dev->id = result;
> > -     sprintf(dev->name, "cdev%d", dev->id);
> > +     snprintf(dev->name, sizeof(dev->name), "cdev%d", dev->id);
> >       result =
> >           sysfs_create_link(&tz->device.kobj, &cdev->device.kobj, dev->name);
> >       if (result)
>
>
> LGTM, please add the tag and re-send so it's on top
> so faster to pick-up for merging
>
> Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>

I've actually applied it already (as 7.1 material), thanks!

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

end of thread, other threads:[~2026-03-06 17:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-23  7:32 [PATCH] thermal: core: Replace sprintf in thermal_bind_cdev_to_trip Thorsten Blum
2026-03-06 14:05 ` Lukasz Luba
2026-03-06 17:49   ` Rafael J. Wysocki

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

all inboxes | Powered by JetHome®