]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
rtc: ab8500: replace sprintf() with sysfs_emit()
authorMaxwell Doose <m32285159@gmail.com>
Sun, 3 May 2026 20:12:36 +0000 (15:12 -0500)
committerAlexandre Belloni <alexandre.belloni@bootlin.com>
Mon, 4 May 2026 16:04:09 +0000 (18:04 +0200)
This patch replaces sprintf() with sysfs_emit() to ensure proper
bounds checking. It also simplifies the return logic by directly
returning the error after logging, instead of logging, calling
sprintf(), then returning.

Reviewed-by: Linus Walleij <linusw@kernel.org>
Signed-off-by: Maxwell Doose <m32285159@gmail.com>
Link: https://patch.msgid.link/20260503201236.29685-1-m32285159@gmail.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
drivers/rtc/rtc-ab8500.c

index ed2b6b8bb3bf8f99fef9f8bee9676f71f8a86d2a..c6147837f9570d60d8fa584393556dac3443a425 100644 (file)
@@ -284,11 +284,10 @@ static ssize_t ab8500_sysfs_show_rtc_calibration(struct device *dev,
        retval = ab8500_rtc_get_calibration(dev, &calibration);
        if (retval < 0) {
                dev_err(dev, "Failed to read RTC calibration attribute\n");
-               sprintf(buf, "0\n");
                return retval;
        }
 
-       return sprintf(buf, "%d\n", calibration);
+       return sysfs_emit(buf, "%d\n", calibration);
 }
 
 static DEVICE_ATTR(rtc_calibration, S_IRUGO | S_IWUSR,