From: Maxwell Doose <m32285159@gmail.com>
To: linusw@kernel.org, alexandre.belloni@bootlin.com
Cc: linux-arm-kernel@lists.infradead.org (moderated
list:ARM/NOMADIK/Ux500 ARCHITECTURES),
linux-rtc@vger.kernel.org (open list:REAL TIME CLOCK (RTC)
SUBSYSTEM), linux-kernel@vger.kernel.org (open list)
Subject: [PATCH RESEND] rtc: ab8500: replace sprintf() with sysfs_emit()
Date: Sun, 3 May 2026 15:12:36 -0500 [thread overview]
Message-ID: <20260503201236.29685-1-m32285159@gmail.com> (raw)
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>
---
note 1: original patch can be found here:
https://lore.kernel.org/linux-rtc/CAD++jLkQD_ZSFPGrx4uL+ezrR1Ai2ddUF9_PpesDG+AEwiDrag@mail.gmail.com/T/#t
note 2: I rebased this on to v7.1-rc1 to make sure there wouldn't be
any merge conflicts.
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,
base-commit: 254f49634ee16a731174d2ae34bc50bd5f45e731
--
2.54.0
next reply other threads:[~2026-05-03 20:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-03 20:12 Maxwell Doose [this message]
2026-05-04 16:04 ` [PATCH RESEND] rtc: ab8500: replace sprintf() with sysfs_emit() Alexandre Belloni
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260503201236.29685-1-m32285159@gmail.com \
--to=m32285159@gmail.com \
--cc=alexandre.belloni@bootlin.com \
--cc=linusw@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox