]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
iio: light: isl29018: replace sprintf() with safer alternatives
authorTomas Borquez <tomasborquez13@gmail.com>
Wed, 26 Nov 2025 20:32:40 +0000 (17:32 -0300)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sun, 21 Dec 2025 11:41:12 +0000 (11:41 +0000)
This patch replaces sprintf() with sysfs_emit() and sysfs_emit_at() safer
alternative with no functional changes.

Signed-off-by: Tomas Borquez <tomasborquez13@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/light/isl29018.c

index 1b4c184230489eb8b0de6c43751120d03dc31a06..b6ab726d1daec5891548a596befdb69ba24bd7c8 100644 (file)
@@ -273,9 +273,9 @@ static ssize_t in_illuminance_scale_available_show
 
        mutex_lock(&chip->lock);
        for (i = 0; i < ARRAY_SIZE(isl29018_scales[chip->int_time]); ++i)
-               len += sprintf(buf + len, "%d.%06d ",
-                              isl29018_scales[chip->int_time][i].scale,
-                              isl29018_scales[chip->int_time][i].uscale);
+               len += sysfs_emit_at(buf, len, "%d.%06d ",
+                                    isl29018_scales[chip->int_time][i].scale,
+                                    isl29018_scales[chip->int_time][i].uscale);
        mutex_unlock(&chip->lock);
 
        buf[len - 1] = '\n';
@@ -293,8 +293,8 @@ static ssize_t in_illuminance_integration_time_available_show
        int len = 0;
 
        for (i = 0; i < ARRAY_SIZE(isl29018_int_utimes[chip->type]); ++i)
-               len += sprintf(buf + len, "0.%06d ",
-                              isl29018_int_utimes[chip->type][i]);
+               len += sysfs_emit_at(buf, len, "0.%06d ",
+                                    isl29018_int_utimes[chip->type][i]);
 
        buf[len - 1] = '\n';
 
@@ -330,7 +330,7 @@ static ssize_t proximity_on_chip_ambient_infrared_suppression_show
         * Return the "proximity scheme" i.e. if the chip does on chip
         * infrared suppression (1 means perform on chip suppression)
         */
-       return sprintf(buf, "%d\n", chip->prox_scheme);
+       return sysfs_emit(buf, "%d\n", chip->prox_scheme);
 }
 
 static ssize_t proximity_on_chip_ambient_infrared_suppression_store