public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Frans Klaver <fransklaver@gmail.com>
Cc: Darren Hart <dvhart@infradead.org>,
	Corentin Chary <corentin.chary@gmail.com>,
	Matthew Garrett <matthew.garrett@nebula.com>,
	acpi4asus-user <acpi4asus-user@lists.sourceforge.net>,
	platform-driver-x86 <platform-driver-x86@vger.kernel.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] eeepc-laptop: remove possible use of uninitialized value
Date: Thu, 4 Sep 2014 07:10:41 -0700	[thread overview]
Message-ID: <20140904141041.GB23299@kroah.com> (raw)
In-Reply-To: <CAH6sp9OaqkdW82HOKMf8gxLLsBzXPCq2HYj7ya+C3YXiFwhgOQ@mail.gmail.com>

On Thu, Sep 04, 2014 at 08:46:40AM +0200, Frans Klaver wrote:
> On Thu, Sep 4, 2014 at 3:14 AM, Greg Kroah-Hartman
> <gregkh@linuxfoundation.org> wrote:
> > On Wed, Sep 03, 2014 at 05:49:47PM -0700, Darren Hart wrote:
> >> On Thu, Sep 04, 2014 at 12:53:25AM +0200, Frans Klaver wrote:
> >> > In store_sys_acpi, if count equals zero, or parse_arg()s sscanf call
> >> > fails, 'value' remains possibly uninitialized. In that case 'value'
> >> > shouldn't be used to produce the store_sys_acpi()s return value.
> 
> Here I should probably remove either 'the' or the 's' after store_sys_acpi().
> 
> 
> >> > Only test the return value of set_acpi() if we can actually call it.
> >> > Return rv otherwise.
> >> >
> >> > Signed-off-by: Frans Klaver <fransklaver@gmail.com>
> >> > ---
> >> >  drivers/platform/x86/eeepc-laptop.c | 8 ++++----
> >> >  1 file changed, 4 insertions(+), 4 deletions(-)
> >> >
> >> > diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c
> >> > index bd533c2..41f12ba 100644
> >> > --- a/drivers/platform/x86/eeepc-laptop.c
> >> > +++ b/drivers/platform/x86/eeepc-laptop.c
> >> > @@ -279,10 +279,10 @@ static ssize_t store_sys_acpi(struct device *dev, int cm,
> >> >     int rv, value;
> >> >
> >> >     rv = parse_arg(buf, count, &value);
> >> > -   if (rv > 0)
> >> > -           value = set_acpi(eeepc, cm, value);
> >>
> >> That was rather horrible wasn't it? :-)
> >>
> >> > -   if (value < 0)
> >> > -           return -EIO;
> >> > +   if (rv > 0) {
> >> > +           if (set_acpi(eeepc, cm, value) < 0)
> >> > +                   return -EIO;
> >>
> >> Is there a compelling reason not to propogate the return code of set_acpi?
> >> (ENODEV specifically). I see -EIO in Documentation/filesystems/sysfs.txt, but
> >> it's used by default if the show() pointer is NULL (for example), but otherwise
> >> propogates the error.
> >>
> >> Specifically it states:
> >>
> >> - show() or store() can always return errors. If a bad value comes
> >>   through, be sure to return an error.
> >>
> >> Greg, does this need to be -EIO? or is returning someting like ENODEV preferable
> >> if it more accurately reflects the error?
> >
> > Just return the value of set_acpi() and you should be fine.
> 
> According to 6dff29b63a5bf2eaf3313cb8a84f0b7520c43401 "eeepc-laptop:
> disp attribute should be write-only" it should be -EIO. -ENODEV would
> be misleading.

If something is "write only" then there should not be a store function
for it at all, the file should not be marked as writable, to prevent
anything from ever being written to it at the higher-level filesystem
layer, and never get down to the driver layer...

thanks,

greg k-h

  reply	other threads:[~2014-09-04 14:10 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-03 22:53 [PATCH] eeepc-laptop: remove possible use of uninitialized value Frans Klaver
2014-09-04  0:49 ` Darren Hart
2014-09-04  1:14   ` Greg Kroah-Hartman
2014-09-04  6:46     ` Frans Klaver
2014-09-04 14:10       ` Greg Kroah-Hartman [this message]
2014-09-04 14:40         ` Frans Klaver
2014-09-04 19:37           ` Paul Bolle
2014-09-04  7:08 ` Paul Bolle
2014-09-04  7:57   ` Frans Klaver
2014-09-06  2:17   ` Darren Hart
2014-09-06 21:17     ` Rafael J. Wysocki
2014-09-08 21:12       ` [PATCH] eeepc-laptop: remove disp attribute show function Frans Klaver
2014-09-08 21:16         ` Greg Kroah-Hartman
     [not found]           ` <20140908212306.GA22145@gmail.com>
     [not found]             ` <20140908214438.GB22145@gmail.com>
2014-09-08 21:57               ` Greg Kroah-Hartman
2014-09-08 23:32                 ` Darren Hart
2014-09-09  8:50       ` [PATCH] eeepc-laptop: remove possible use of uninitialized value Paul Bolle
2014-09-10  3:33         ` Darren Hart
2014-09-10 14:42           ` Frans Klaver
2014-09-10 16:49             ` Darren Hart
2014-09-10 20:05               ` [PATCH v2] eeepc-laptop: simplify parse_arg() Paul Bolle
2014-09-11 22:37                 ` Darren Hart
2014-09-16 23:45                   ` Darren Hart
2014-09-17 19:02                     ` [PATCH v3] " Paul Bolle
2014-09-17 20:14                       ` Darren Hart
2014-09-17 20:35                       ` Darren Hart
2014-09-17 20:36                         ` Frans Klaver
2014-09-17 21:39                         ` Frans Klaver
2014-09-09  0:06 ` [PATCH] eeepc-laptop: remove possible use of uninitialized value Darren Hart

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=20140904141041.GB23299@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=acpi4asus-user@lists.sourceforge.net \
    --cc=corentin.chary@gmail.com \
    --cc=dvhart@infradead.org \
    --cc=fransklaver@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matthew.garrett@nebula.com \
    --cc=platform-driver-x86@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