From: Joe Perches <joe@perches.com>
To: Juerg Haefliger <juerg.haefliger@canonical.com>,
wim@linux-watchdog.org, linux@roeck-us.net, joel@jms.id.au,
linux-watchdog@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-aspeed@lists.ozlabs.org
Cc: andrew@aj.id.au, linux-kernel@vger.kernel.org,
Juerg Haefliger <juergh@canonical.com>
Subject: Re: [PATCH] watchdog: Use sysfs_emit() and sysfs_emit_at() in "show" functions
Date: Wed, 12 May 2021 21:48:37 -0700 [thread overview]
Message-ID: <f2e616645f311ccaf6e0acb996f8c4360a0480ec.camel@perches.com> (raw)
In-Reply-To: <20210511061812.480172-1-juergh@canonical.com>
On Tue, 2021-05-11 at 08:18 +0200, Juerg Haefliger wrote:
> Convert sprintf() in sysfs "show" functions to sysfs_emit() and
> sysfs_emit_at() in order to check for buffer overruns in sysfs outputs.
[]
> diff --git a/drivers/watchdog/ziirave_wdt.c b/drivers/watchdog/ziirave_wdt.c
[]
> @@ -445,8 +445,9 @@ static ssize_t ziirave_wdt_sysfs_show_firm(struct device *dev,
> if (ret)
> return ret;
>
>
> - ret = sprintf(buf, ZIIRAVE_FW_VERSION_FMT, w_priv->firmware_rev.major,
> - w_priv->firmware_rev.minor);
> + ret = sysfs_emit(buf, ZIIRAVE_FW_VERSION_FMT,
> + w_priv->firmware_rev.major,
> + w_priv->firmware_rev.minor);
>
>
> mutex_unlock(&w_priv->sysfs_mutex);
>
>
> @@ -468,8 +469,9 @@ static ssize_t ziirave_wdt_sysfs_show_boot(struct device *dev,
> if (ret)
> return ret;
>
>
> - ret = sprintf(buf, ZIIRAVE_BL_VERSION_FMT, w_priv->bootloader_rev.major,
> - w_priv->bootloader_rev.minor);
> + ret = sysfs_emit(buf, ZIIRAVE_BL_VERSION_FMT,
> + w_priv->bootloader_rev.major,
> + w_priv->bootloader_rev.minor);
>
>
> mutex_unlock(&w_priv->sysfs_mutex);
>
>
> @@ -491,7 +493,7 @@ static ssize_t ziirave_wdt_sysfs_show_reason(struct device *dev,
> if (ret)
> return ret;
>
>
> - ret = sprintf(buf, "%s", ziirave_reasons[w_priv->reset_reason]);
> + ret = sysfs_emit(buf, "%s", ziirave_reasons[w_priv->reset_reason]);
All of these formats should probably end with a newline
and the ZIIRAVE_<FOO>_VERSION_FMT defines are to me unnecessary.
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2021-05-13 4:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-11 6:18 [PATCH] watchdog: Use sysfs_emit() and sysfs_emit_at() in "show" functions Juerg Haefliger
2021-05-11 13:35 ` Guenter Roeck
2021-05-13 4:48 ` Joe Perches [this message]
2021-05-20 6:30 ` Juerg Haefliger
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=f2e616645f311ccaf6e0acb996f8c4360a0480ec.camel@perches.com \
--to=joe@perches.com \
--cc=andrew@aj.id.au \
--cc=joel@jms.id.au \
--cc=juerg.haefliger@canonical.com \
--cc=juergh@canonical.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-aspeed@lists.ozlabs.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=wim@linux-watchdog.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;
as well as URLs for NNTP newsgroup(s).