[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20210520083052.68a0e1d9@smeagol>
Date: Thu, 20 May 2021 08:30:52 +0200
From: Juerg Haefliger <juerg.haefliger@...onical.com>
To: Joe Perches <joe@...ches.com>
Cc: Juerg Haefliger <juerg.haefliger@...onical.com>,
wim@...ux-watchdog.org, linux@...ck-us.net, joel@....id.au,
linux-watchdog@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org,
linux-aspeed@...ts.ozlabs.org, andrew@...id.au,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] watchdog: Use sysfs_emit() and sysfs_emit_at() in
"show" functions
On Wed, 12 May 2021 21:48:37 -0700
Joe Perches <joe@...ches.com> wrote:
> 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.
>
I'll send a follow-on patch for that.
...Juerg
Content of type "application/pgp-signature" skipped
Powered by blists - more mailing lists