linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Juerg Haefliger <juerg.haefliger@canonical.com>
To: Joe Perches <joe@perches.com>
Cc: 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, andrew@aj.id.au,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] watchdog: Use sysfs_emit() and sysfs_emit_at() in "show" functions
Date: Thu, 20 May 2021 08:30:52 +0200	[thread overview]
Message-ID: <20210520083052.68a0e1d9@smeagol> (raw)
In-Reply-To: <f2e616645f311ccaf6e0acb996f8c4360a0480ec.camel@perches.com>


[-- Attachment #1.1: Type: text/plain, Size: 1794 bytes --]

On Wed, 12 May 2021 21:48:37 -0700
Joe Perches <joe@perches.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

[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

      reply	other threads:[~2021-05-20  6:33 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
2021-05-20  6:30   ` Juerg Haefliger [this message]

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=20210520083052.68a0e1d9@smeagol \
    --to=juerg.haefliger@canonical.com \
    --cc=andrew@aj.id.au \
    --cc=joe@perches.com \
    --cc=joel@jms.id.au \
    --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).