Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1519152
| From | Arnd Bergmann <arnd@arndb.de> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v2 03/11] x86: apm: avoid uninitialized data |
| Date | 2016-11-10 18:00 +0100 |
| Message-ID | <sC0RN-ke-19@gated-at.bofh.it> (permalink) |
| References | <sC0I2-h7-11@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
apm_bios_call() can fail, and return a status in its argument
structure. If that status however is zero during a call from
apm_get_power_status(), we end up using data that may have
never been set, as reported by "gcc -Wmaybe-uninitialized":
arch/x86/kernel/apm_32.c: In function ‘apm’:
arch/x86/kernel/apm_32.c:1729:17: error: ‘bx’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
arch/x86/kernel/apm_32.c:1835:5: error: ‘cx’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
arch/x86/kernel/apm_32.c:1730:17: note: ‘cx’ was declared here
arch/x86/kernel/apm_32.c:1842:27: error: ‘dx’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
arch/x86/kernel/apm_32.c:1731:17: note: ‘dx’ was declared here
This changes the function to return "APM_NO_ERROR" here, which
makes the code more robust to broken BIOS versions, and avoids
the warning.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Jiri Kosina <jkosina@suse.cz>
Reviewed-by: Luis R. Rodriguez <mcgrof@kernel.org>
---
arch/x86/kernel/apm_32.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
index c7364bd..51287cd 100644
--- a/arch/x86/kernel/apm_32.c
+++ b/arch/x86/kernel/apm_32.c
@@ -1042,8 +1042,11 @@ static int apm_get_power_status(u_short *status, u_short *bat, u_short *life)
if (apm_info.get_power_status_broken)
return APM_32_UNSUPPORTED;
- if (apm_bios_call(&call))
+ if (apm_bios_call(&call)) {
+ if (!call.err)
+ return APM_NO_ERROR;
return call.err;
+ }
*status = call.ebx;
*bat = call.ecx;
if (apm_info.get_power_status_swabinminutes) {
--
2.9.0
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v2 00/11] getting back -Wmaybe-uninitialized Arnd Bergmann <arnd@arndb.de> - 2016-11-10 17:50 +0100
[PATCH v2 01/11] Kbuild: enable -Wmaybe-uninitialized warning for "make W=1" Arnd Bergmann <arnd@arndb.de> - 2016-11-10 17:50 +0100
[PATCH v2 06/11] [media] dib0700: fix nec repeat handling Arnd Bergmann <arnd@arndb.de> - 2016-11-10 17:50 +0100
[PATCH v2 10/11] pcmcia: fix return value of soc_pcmcia_regulator_set Arnd Bergmann <arnd@arndb.de> - 2016-11-10 17:50 +0100
[PATCH v2 07/11] [media] rc: print correct variable for z8f0811 Arnd Bergmann <arnd@arndb.de> - 2016-11-10 17:50 +0100
[PATCH v2 08/11] crypto: aesni: shut up -Wmaybe-uninitialized warning Arnd Bergmann <arnd@arndb.de> - 2016-11-10 17:50 +0100
[PATCH v2 02/11] NFSv4.1: work around -Wmaybe-uninitialized warning Arnd Bergmann <arnd@arndb.de> - 2016-11-10 17:50 +0100
[PATCH v2 11/11] Kbuild: enable -Wmaybe-uninitialized warnings by default Arnd Bergmann <arnd@arndb.de> - 2016-11-10 17:50 +0100
[PATCH v2 09/11] [v3] infiniband: shut up a maybe-uninitialized warning Arnd Bergmann <arnd@arndb.de> - 2016-11-10 18:00 +0100
[PATCH v2 03/11] x86: apm: avoid uninitialized data Arnd Bergmann <arnd@arndb.de> - 2016-11-10 18:00 +0100
Re: [PATCH v2 00/11] getting back -Wmaybe-uninitialized Linus Torvalds <torvalds@linux-foundation.org> - 2016-11-11 18:20 +0100
Re: [PATCH v2 00/11] getting back -Wmaybe-uninitialized Arnd Bergmann <arnd@arndb.de> - 2016-11-11 21:00 +0100
csiph-web