Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1379274
| From | "Gabriel L. Somlo" <somlo@cmu.edu> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [patch] firmware: qemu_fw_cfg.c: potential unintialized variable |
| Date | 2016-04-14 22:00 +0200 |
| Message-ID | <rnVAJ-7pv-3@gated-at.bofh.it> (permalink) |
| References | <rnLUL-83r-43@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Thu, Apr 14, 2016 at 12:33:37PM +0300, Dan Carpenter wrote:
> It acpi_acquire_global_lock() return AE_NOT_CONFIGURED then "glk" isn't
> initialized, which, if you got very unlucky, could cause a bug.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/drivers/firmware/qemu_fw_cfg.c b/drivers/firmware/qemu_fw_cfg.c
> index d999fe3..0e20116 100644
> --- a/drivers/firmware/qemu_fw_cfg.c
> +++ b/drivers/firmware/qemu_fw_cfg.c
> @@ -77,7 +77,7 @@ static inline u16 fw_cfg_sel_endianness(u16 key)
> static inline void fw_cfg_read_blob(u16 key,
> void *buf, loff_t pos, size_t count)
> {
> - u32 glk;
> + u32 glk = -1U;
After digging through the acpi_[acquire|release]_global_lock() code in
drivers/acpi/acpica/evxface.c, the -1 value actually makes sense, as
glk is set to the value of acpi_gbl_global_lock_handle, which
internally is a 16-bit value which can wrap around, but will never be
equal to 32-bit "-1". As such, the unlock function would fail with
AE_NOT_ACQUIRED if its "for-real" version ever ended up being called.
So, with the typos in the commit blurb fixed (s/It/If/ and
s/return/returns/), and on general "belt-and-suspenders" principle,
Reviewed-by: Gabriel Somlo <somlo@cmu.edu>
I just wanted to make sure my understanding of "this can't happen with
the way the ACPI macros are currently defined" is still correct :)
Thanks,
--Gabe
> acpi_status status;
>
> /* If we have ACPI, ensure mutual exclusion against any potential
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
[patch] firmware: qemu_fw_cfg.c: potential unintialized variable Dan Carpenter <dan.carpenter@oracle.com> - 2016-04-14 11:40 +0200
Re: [patch] firmware: qemu_fw_cfg.c: potential unintialized variable "Gabriel L. Somlo" <somlo@cmu.edu> - 2016-04-14 20:50 +0200
Re: [patch] firmware: qemu_fw_cfg.c: potential unintialized variable Dan Carpenter <dan.carpenter@oracle.com> - 2016-04-14 21:20 +0200
Re: [patch] firmware: qemu_fw_cfg.c: potential unintialized variable "Gabriel L. Somlo" <somlo@cmu.edu> - 2016-04-14 21:40 +0200
Re: [patch] firmware: qemu_fw_cfg.c: potential unintialized variable Dan Carpenter <dan.carpenter@oracle.com> - 2016-04-14 22:10 +0200
Re: [patch] firmware: qemu_fw_cfg.c: potential unintialized variable "Gabriel L. Somlo" <somlo@cmu.edu> - 2016-04-14 22:00 +0200
csiph-web