* [PATCH] platform/x86: thinkpad_acpi: initialize tp_nvram_state variable
@ 2020-09-13 19:02 trix
2020-09-14 8:39 ` Hans de Goede
2020-09-17 21:46 ` mark gross
0 siblings, 2 replies; 3+ messages in thread
From: trix @ 2020-09-13 19:02 UTC (permalink / raw)
To: ibm-acpi, dvhart, andy, natechancellor, ndesaulniers, len.brown
Cc: ibm-acpi-devel, platform-driver-x86, linux-kernel,
clang-built-linux, Tom Rix
From: Tom Rix <trix@redhat.com>
clang static analysis flags this represenative problem
thinkpad_acpi.c:2523:7: warning: Branch condition evaluates
to a garbage value
if (!oldn->mute ||
^~~~~~~~~~~
In hotkey_kthread() mute is conditionally set by hotkey_read_nvram()
but unconditionally checked by hotkey_compare_and_issue_event().
So the tp_nvram_state variable s[2] needs to be initialized.
Fixes: 01e88f25985d ("ACPI: thinkpad-acpi: add CMOS NVRAM polling for hot keys (v9)")
Signed-off-by: Tom Rix <trix@redhat.com>
---
drivers/platform/x86/thinkpad_acpi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index 47925c319d7b..24da8b6872f2 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -2573,7 +2573,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
*/
static int hotkey_kthread(void *data)
{
- struct tp_nvram_state s[2];
+ struct tp_nvram_state s[2] = { 0 };
u32 poll_mask, event_mask;
unsigned int si, so;
unsigned long t;
--
2.18.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] platform/x86: thinkpad_acpi: initialize tp_nvram_state variable
2020-09-13 19:02 [PATCH] platform/x86: thinkpad_acpi: initialize tp_nvram_state variable trix
@ 2020-09-14 8:39 ` Hans de Goede
2020-09-17 21:46 ` mark gross
1 sibling, 0 replies; 3+ messages in thread
From: Hans de Goede @ 2020-09-14 8:39 UTC (permalink / raw)
To: trix, ibm-acpi, dvhart, andy, natechancellor, ndesaulniers, len.brown
Cc: ibm-acpi-devel, platform-driver-x86, linux-kernel, clang-built-linux
Hi,
On 9/13/20 9:02 PM, trix@redhat.com wrote:
> From: Tom Rix <trix@redhat.com>
>
> clang static analysis flags this represenative problem
> thinkpad_acpi.c:2523:7: warning: Branch condition evaluates
> to a garbage value
> if (!oldn->mute ||
> ^~~~~~~~~~~
>
> In hotkey_kthread() mute is conditionally set by hotkey_read_nvram()
> but unconditionally checked by hotkey_compare_and_issue_event().
> So the tp_nvram_state variable s[2] needs to be initialized.
>
> Fixes: 01e88f25985d ("ACPI: thinkpad-acpi: add CMOS NVRAM polling for hot keys (v9)")
Looking at the code I do not think this can actually happen,
this can only happen if the poll_mask == 0 the first time
through the loop so s[1] does never gets initialized and then
the second time to the loop poll_mask != 0, but if poll_mask
changes then we hit:
mutex_lock(&hotkey_thread_data_mutex);
if (was_frozen || hotkey_config_change != change_detector) {
/* forget old state on thaw or config change */
si = so;
t = 0;
change_detector = hotkey_config_change;
}
Where we set si = so so then this can also not happen.
I can understand the static-analyzer warning about this, and fixing
that warning is good. But I doubt that this warrants a fixes tag.
So with the Fixes tag dropped this is:
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
> Signed-off-by: Tom Rix <trix@redhat.com>
> ---
> drivers/platform/x86/thinkpad_acpi.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
> index 47925c319d7b..24da8b6872f2 100644
> --- a/drivers/platform/x86/thinkpad_acpi.c
> +++ b/drivers/platform/x86/thinkpad_acpi.c
> @@ -2573,7 +2573,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
> */
> static int hotkey_kthread(void *data)
> {
> - struct tp_nvram_state s[2];
> + struct tp_nvram_state s[2] = { 0 };
> u32 poll_mask, event_mask;
> unsigned int si, so;
> unsigned long t;
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] platform/x86: thinkpad_acpi: initialize tp_nvram_state variable
2020-09-13 19:02 [PATCH] platform/x86: thinkpad_acpi: initialize tp_nvram_state variable trix
2020-09-14 8:39 ` Hans de Goede
@ 2020-09-17 21:46 ` mark gross
1 sibling, 0 replies; 3+ messages in thread
From: mark gross @ 2020-09-17 21:46 UTC (permalink / raw)
To: trix
Cc: ibm-acpi, dvhart, andy, natechancellor, ndesaulniers, len.brown,
ibm-acpi-devel, platform-driver-x86, linux-kernel,
clang-built-linux
Acked-by: mark gross <mgross@linux.intel.com>
--mark
On Sun, Sep 13, 2020 at 12:02:03PM -0700, trix@redhat.com wrote:
> From: Tom Rix <trix@redhat.com>
>
> clang static analysis flags this represenative problem
> thinkpad_acpi.c:2523:7: warning: Branch condition evaluates
> to a garbage value
> if (!oldn->mute ||
> ^~~~~~~~~~~
>
> In hotkey_kthread() mute is conditionally set by hotkey_read_nvram()
> but unconditionally checked by hotkey_compare_and_issue_event().
> So the tp_nvram_state variable s[2] needs to be initialized.
>
> Fixes: 01e88f25985d ("ACPI: thinkpad-acpi: add CMOS NVRAM polling for hot keys (v9)")
> Signed-off-by: Tom Rix <trix@redhat.com>
> ---
> drivers/platform/x86/thinkpad_acpi.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
> index 47925c319d7b..24da8b6872f2 100644
> --- a/drivers/platform/x86/thinkpad_acpi.c
> +++ b/drivers/platform/x86/thinkpad_acpi.c
> @@ -2573,7 +2573,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
> */
> static int hotkey_kthread(void *data)
> {
> - struct tp_nvram_state s[2];
> + struct tp_nvram_state s[2] = { 0 };
> u32 poll_mask, event_mask;
> unsigned int si, so;
> unsigned long t;
> --
> 2.18.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-09-17 21:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-13 19:02 [PATCH] platform/x86: thinkpad_acpi: initialize tp_nvram_state variable trix
2020-09-14 8:39 ` Hans de Goede
2020-09-17 21:46 ` mark gross
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.