* [PATCH] iwlwifi: mvm: return an error if setting tbl_rev fails
@ 2022-07-02 15:10 Tom Rix
2022-07-07 21:55 ` Nick Desaulniers
0 siblings, 1 reply; 2+ messages in thread
From: Tom Rix @ 2022-07-02 15:10 UTC (permalink / raw)
To: gregory.greenman, kvalo, davem, edumazet, kuba, pabeni, nathan,
ndesaulniers, luciano.coelho, ayala.barazani,
miriam.rachel.korenblit, johannes.berg, matt.chen
Cc: linux-wireless, netdev, linux-kernel, llvm, Tom Rix
clang static analysis reports
drivers/net/wireless/intel/iwlwifi/fw/acpi.c:1048:17: warning: Assigned value is garbage or undefined [core.uninitialized.Assign]
fwrt->ppag_ver = tbl_rev;
^ ~~~~~~~
tbl_rev is optionaly set by a series of calls to iwl_acpi_get_wifi_pkg()
and then jumping to the read_table when a call is successful. The
error case when all the call fails is not handled. On all failed,
the code flow falls through to the read_table label. Add an error
handler for the all fail case.
Fixes: e8e10a37c51c ("iwlwifi: acpi: move ppag code from mvm to fw/acpi")
Signed-off-by: Tom Rix <trix@redhat.com>
---
drivers/net/wireless/intel/iwlwifi/fw/acpi.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/acpi.c b/drivers/net/wireless/intel/iwlwifi/fw/acpi.c
index e6d64152c81a..1ef1e26c3206 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/acpi.c
+++ b/drivers/net/wireless/intel/iwlwifi/fw/acpi.c
@@ -1044,6 +1044,9 @@ int iwl_acpi_get_ppag_table(struct iwl_fw_runtime *fwrt)
goto read_table;
}
+ ret = -EINVAL;
+ goto out_free;
+
read_table:
fwrt->ppag_ver = tbl_rev;
flags = &wifi_pkg->package.elements[1];
--
2.27.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] iwlwifi: mvm: return an error if setting tbl_rev fails
2022-07-02 15:10 [PATCH] iwlwifi: mvm: return an error if setting tbl_rev fails Tom Rix
@ 2022-07-07 21:55 ` Nick Desaulniers
0 siblings, 0 replies; 2+ messages in thread
From: Nick Desaulniers @ 2022-07-07 21:55 UTC (permalink / raw)
To: Tom Rix
Cc: gregory.greenman, kvalo, davem, edumazet, kuba, pabeni, nathan,
luciano.coelho, ayala.barazani, miriam.rachel.korenblit,
johannes.berg, matt.chen, linux-wireless, netdev, linux-kernel,
llvm
On Sat, Jul 2, 2022 at 8:10 AM Tom Rix <trix@redhat.com> wrote:
>
> clang static analysis reports
> drivers/net/wireless/intel/iwlwifi/fw/acpi.c:1048:17: warning: Assigned value is garbage or undefined [core.uninitialized.Assign]
> fwrt->ppag_ver = tbl_rev;
> ^ ~~~~~~~
> tbl_rev is optionaly set by a series of calls to iwl_acpi_get_wifi_pkg()
> and then jumping to the read_table when a call is successful. The
> error case when all the call fails is not handled. On all failed,
> the code flow falls through to the read_table label. Add an error
> handler for the all fail case.
>
> Fixes: e8e10a37c51c ("iwlwifi: acpi: move ppag code from mvm to fw/acpi")
> Signed-off-by: Tom Rix <trix@redhat.com>
> ---
> drivers/net/wireless/intel/iwlwifi/fw/acpi.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/net/wireless/intel/iwlwifi/fw/acpi.c b/drivers/net/wireless/intel/iwlwifi/fw/acpi.c
> index e6d64152c81a..1ef1e26c3206 100644
> --- a/drivers/net/wireless/intel/iwlwifi/fw/acpi.c
> +++ b/drivers/net/wireless/intel/iwlwifi/fw/acpi.c
> @@ -1044,6 +1044,9 @@ int iwl_acpi_get_ppag_table(struct iwl_fw_runtime *fwrt)
> goto read_table;
Thanks for the patch!
I wonder why the pre-existing code had a goto to a label that was the
subsequent statement? That's strange; maybe something was in between
them before, was removed, and that wasn't cleaned up?
I think the whole `if (!IS_ERR(wifi_pkg))` block would be clearer if this was:
...
wifi_pkg = iwl_acpi_get_wifi_pkg(fwrt->dev, data,
ACPI_PPAG_WIFI_DATA_SIZE_V1, &tbl_rev);
if (IS_ERR(wifi_pkg) || tbl_rev != 0) {
ret = -EINVAL;
goto out_free;
}
num_sub_bands = IWL_NUM_SUB_BANDS_V1;
IWL_DEBUG_RADIO(fwrt, "Reading PPAG table v1 (tbl_rev=0)\n");
read_table:
...
rather than the existing spaghetti. Apologies for my formatting.
> }
>
> + ret = -EINVAL;
> + goto out_free;
> +
> read_table:
> fwrt->ppag_ver = tbl_rev;
> flags = &wifi_pkg->package.elements[1];
> --
> 2.27.0
>
--
Thanks,
~Nick Desaulniers
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-07-07 21:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-02 15:10 [PATCH] iwlwifi: mvm: return an error if setting tbl_rev fails Tom Rix
2022-07-07 21:55 ` Nick Desaulniers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).