]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
thermal: core: Replace sprintf() in thermal_bind_cdev_to_trip()
authorThorsten Blum <thorsten.blum@linux.dev>
Mon, 23 Feb 2026 07:32:45 +0000 (08:32 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 6 Mar 2026 16:57:58 +0000 (17:57 +0100)
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>
Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
[ rjw: Subject tweaks ]
Link: https://patch.msgid.link/20260223073245.321298-2-thorsten.blum@linux.dev
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/thermal/thermal_core.c

index b7d706ed7ed96a4be3a2e2abe9d87d1b72b03651..479916b67f480c1b421a2ab379ddaa071a79791d 100644 (file)
@@ -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)