All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] eeepc-laptop: remove possible use of uninitialized value
@ 2014-09-03 22:53 Frans Klaver
  2014-09-04  0:49 ` Darren Hart
                   ` (2 more replies)
  0 siblings, 3 replies; 28+ messages in thread
From: Frans Klaver @ 2014-09-03 22:53 UTC (permalink / raw)
  To: Corentin Chary
  Cc: Frans Klaver, Matthew Garrett, acpi4asus-user,
	platform-driver-x86, linux-kernel

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.

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);
-	if (value < 0)
-		return -EIO;
+	if (rv > 0) {
+		if (set_acpi(eeepc, cm, value) < 0)
+			return -EIO;
+	}
 	return rv;
 }
 
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2014-09-17 21:39 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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-09  8:50       ` 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-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  0:06 ` [PATCH] eeepc-laptop: remove possible use of uninitialized value Darren Hart

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.