* [PATCH] rtc: ab8500: replace sprintf() with sysfs_emit()
@ 2026-04-19 22:36 Maxwell Doose
2026-04-21 11:21 ` Linus Walleij
0 siblings, 1 reply; 2+ messages in thread
From: Maxwell Doose @ 2026-04-19 22:36 UTC (permalink / raw)
To: linusw, alexandre.belloni; +Cc: linux-arm-kernel, linux-rtc, linux-kernel
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.
Signed-off-by: Maxwell Doose <m32285159@gmail.com>
---
drivers/rtc/rtc-ab8500.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/rtc/rtc-ab8500.c b/drivers/rtc/rtc-ab8500.c
index ed2b6b8bb3bf..c6147837f957 100644
--- a/drivers/rtc/rtc-ab8500.c
+++ b/drivers/rtc/rtc-ab8500.c
@@ -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,
--
2.53.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] rtc: ab8500: replace sprintf() with sysfs_emit()
2026-04-19 22:36 [PATCH] rtc: ab8500: replace sprintf() with sysfs_emit() Maxwell Doose
@ 2026-04-21 11:21 ` Linus Walleij
0 siblings, 0 replies; 2+ messages in thread
From: Linus Walleij @ 2026-04-21 11:21 UTC (permalink / raw)
To: Maxwell Doose
Cc: alexandre.belloni, linux-arm-kernel, linux-rtc, linux-kernel
On Mon, Apr 20, 2026 at 12:36 AM Maxwell Doose <m32285159@gmail.com> wrote:
> 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.
>
> Signed-off-by: Maxwell Doose <m32285159@gmail.com>
Reviewed-by: Linus Walleij <linusw@kernel.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-04-21 11:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-19 22:36 [PATCH] rtc: ab8500: replace sprintf() with sysfs_emit() Maxwell Doose
2026-04-21 11:21 ` Linus Walleij
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox