* [PATCH 3/14 v3] ath9k: Check the return value of pcie_capability_read_*()
[not found] <20200713175529.29715-1-refactormyself@gmail.com>
@ 2020-07-13 17:55 ` Saheed O. Bolarinwa
2020-07-20 17:09 ` Kalle Valo
2020-07-13 17:55 ` [PATCH 4/14 v3] iwlegacy: " Saheed O. Bolarinwa
` (2 subsequent siblings)
3 siblings, 1 reply; 7+ messages in thread
From: Saheed O. Bolarinwa @ 2020-07-13 17:55 UTC (permalink / raw)
To: skhan, linux-pci, linux-kernel-mentees, linux-kernel,
QCA ath9k Development, linux-wireless, netdev
Cc: Bolarinwa Olayemi Saheed, Kalle Valo
From: Bolarinwa Olayemi Saheed <refactormyself@gmail.com>
On failure pcie_capability_read_dword() sets it's last parameter, val
to 0. However, with Patch 14/14, it is possible that val is set to ~0 on
failure. This would introduce a bug because (x & x) == (~0 & x).
This bug can be avoided without changing the function's behaviour if the
return value of pcie_capability_read_dword is checked to confirm success.
Check the return value of pcie_capability_read_dword() to ensure success.
Suggested-by: Bjorn Helgaas <bjorn@helgaas.com>
Signed-off-by: Bolarinwa Olayemi Saheed <refactormyself@gmail.com>
---
drivers/net/wireless/ath/ath9k/pci.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/net/wireless/ath/ath9k/pci.c b/drivers/net/wireless/ath/ath9k/pci.c
index f3461b193c7a..cff9af3af38d 100644
--- a/drivers/net/wireless/ath/ath9k/pci.c
+++ b/drivers/net/wireless/ath/ath9k/pci.c
@@ -825,6 +825,7 @@ static void ath_pci_aspm_init(struct ath_common *common)
struct pci_dev *pdev = to_pci_dev(sc->dev);
struct pci_dev *parent;
u16 aspm;
+ int ret;
if (!ah->is_pciexpress)
return;
@@ -866,8 +867,8 @@ static void ath_pci_aspm_init(struct ath_common *common)
if (AR_SREV_9462(ah))
pci_read_config_dword(pdev, 0x70c, &ah->config.aspm_l1_fix);
- pcie_capability_read_word(parent, PCI_EXP_LNKCTL, &aspm);
- if (aspm & (PCI_EXP_LNKCTL_ASPM_L0S | PCI_EXP_LNKCTL_ASPM_L1)) {
+ ret = pcie_capability_read_word(parent, PCI_EXP_LNKCTL, &aspm);
+ if (!ret && (aspm & (PCI_EXP_LNKCTL_ASPM_L0S | PCI_EXP_LNKCTL_ASPM_L1))) {
ah->aspm_enabled = true;
/* Initialize PCIe PM and SERDES registers. */
ath9k_hw_configpcipowersave(ah, false);
--
2.18.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 4/14 v3] iwlegacy: Check the return value of pcie_capability_read_*()
[not found] <20200713175529.29715-1-refactormyself@gmail.com>
2020-07-13 17:55 ` [PATCH 3/14 v3] ath9k: Check the return value of pcie_capability_read_*() Saheed O. Bolarinwa
@ 2020-07-13 17:55 ` Saheed O. Bolarinwa
2020-07-15 16:47 ` Kalle Valo
2020-07-13 17:55 ` [PATCH 8/14 v3] PCI/ACPI: " Saheed O. Bolarinwa
2020-07-13 17:55 ` [PATCH 12/14 v3] PCI/AER: " Saheed O. Bolarinwa
3 siblings, 1 reply; 7+ messages in thread
From: Saheed O. Bolarinwa @ 2020-07-13 17:55 UTC (permalink / raw)
To: skhan, linux-pci, linux-kernel-mentees, linux-kernel,
Stanislaw Gruszka, linux-wireless, netdev
Cc: Bolarinwa Olayemi Saheed, Kalle Valo
From: Bolarinwa Olayemi Saheed <refactormyself@gmail.com>
On failure pcie_capability_read_dword() sets it's last parameter, val
to 0. However, with Patch 14/14, it is possible that val is set to ~0 on
failure. This would introduce a bug because (x & x) == (~0 & x).
This bug can be avoided without changing the function's behaviour if the
return value of pcie_capability_read_dword is checked to confirm success.
Check the return value of pcie_capability_read_dword() to ensure success.
Suggested-by: Bjorn Helgaas <bjorn@helgaas.com>
Signed-off-by: Bolarinwa Olayemi Saheed <refactormyself@gmail.com>
---
drivers/net/wireless/intel/iwlegacy/common.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/wireless/intel/iwlegacy/common.c b/drivers/net/wireless/intel/iwlegacy/common.c
index 348c17ce72f5..f78e062df572 100644
--- a/drivers/net/wireless/intel/iwlegacy/common.c
+++ b/drivers/net/wireless/intel/iwlegacy/common.c
@@ -4286,8 +4286,8 @@ il_apm_init(struct il_priv *il)
* power savings, even without L1.
*/
if (il->cfg->set_l0s) {
- pcie_capability_read_word(il->pci_dev, PCI_EXP_LNKCTL, &lctl);
- if (lctl & PCI_EXP_LNKCTL_ASPM_L1) {
+ ret = pcie_capability_read_word(il->pci_dev, PCI_EXP_LNKCTL, &lctl);
+ if (!ret && (lctl & PCI_EXP_LNKCTL_ASPM_L1)) {
/* L1-ASPM enabled; disable(!) L0S */
il_set_bit(il, CSR_GIO_REG,
CSR_GIO_REG_VAL_L0S_ENABLED);
--
2.18.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 8/14 v3] PCI/ACPI: Check the return value of pcie_capability_read_*()
[not found] <20200713175529.29715-1-refactormyself@gmail.com>
2020-07-13 17:55 ` [PATCH 3/14 v3] ath9k: Check the return value of pcie_capability_read_*() Saheed O. Bolarinwa
2020-07-13 17:55 ` [PATCH 4/14 v3] iwlegacy: " Saheed O. Bolarinwa
@ 2020-07-13 17:55 ` Saheed O. Bolarinwa
2020-07-14 13:27 ` Rafael J. Wysocki
2020-07-13 17:55 ` [PATCH 12/14 v3] PCI/AER: " Saheed O. Bolarinwa
3 siblings, 1 reply; 7+ messages in thread
From: Saheed O. Bolarinwa @ 2020-07-13 17:55 UTC (permalink / raw)
To: skhan, linux-acpi, linux-pci, linux-kernel-mentees, linux-kernel
Cc: Bolarinwa Olayemi Saheed
From: Bolarinwa Olayemi Saheed <refactormyself@gmail.com>
On failure pcie_capability_read_dword() sets it's last parameter,
val to 0.
However, with Patch 14/14, it is possible that val is set to ~0 on
failure. This would introduce a bug because (x & x) == (~0 & x).
This bug can be avoided if the return value of pcie_capability_read_word
is checked to confirm success.
Check the return value of pcie_capability_read_word() to ensure success.
Suggested-by: Bjorn Helgaas <bjorn@helgaas.com>
Signed-off-by: Bolarinwa Olayemi Saheed <refactormyself@gmail.com>
---
drivers/pci/pci-acpi.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index 7224b1e5f2a8..39eb816bc3b8 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -248,12 +248,13 @@ static bool pcie_root_rcb_set(struct pci_dev *dev)
{
struct pci_dev *rp = pcie_find_root_port(dev);
u16 lnkctl;
+ int ret;
if (!rp)
return false;
- pcie_capability_read_word(rp, PCI_EXP_LNKCTL, &lnkctl);
- if (lnkctl & PCI_EXP_LNKCTL_RCB)
+ ret = pcie_capability_read_word(rp, PCI_EXP_LNKCTL, &lnkctl);
+ if (!ret && (lnkctl & PCI_EXP_LNKCTL_RCB))
return true;
return false;
@@ -792,12 +793,13 @@ bool pciehp_is_native(struct pci_dev *bridge)
{
const struct pci_host_bridge *host;
u32 slot_cap;
+ int ret;
if (!IS_ENABLED(CONFIG_HOTPLUG_PCI_PCIE))
return false;
- pcie_capability_read_dword(bridge, PCI_EXP_SLTCAP, &slot_cap);
- if (!(slot_cap & PCI_EXP_SLTCAP_HPC))
+ ret = pcie_capability_read_dword(bridge, PCI_EXP_SLTCAP, &slot_cap);
+ if (ret || !(slot_cap & PCI_EXP_SLTCAP_HPC))
return false;
if (pcie_ports_native)
--
2.18.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 12/14 v3] PCI/AER: Check the return value of pcie_capability_read_*()
[not found] <20200713175529.29715-1-refactormyself@gmail.com>
` (2 preceding siblings ...)
2020-07-13 17:55 ` [PATCH 8/14 v3] PCI/ACPI: " Saheed O. Bolarinwa
@ 2020-07-13 17:55 ` Saheed O. Bolarinwa
3 siblings, 0 replies; 7+ messages in thread
From: Saheed O. Bolarinwa @ 2020-07-13 17:55 UTC (permalink / raw)
To: skhan, linux-pci, linuxppc-dev, linux-kernel-mentees, linux-kernel
Cc: Bolarinwa Olayemi Saheed
From: Bolarinwa Olayemi Saheed <refactormyself@gmail.com>
On failure pcie_capability_read_dword() sets it's last parameter,
val to 0.
However, with Patch 14/14, it is possible that val is set to ~0 on
failure. This would introduce a bug because (x & x) == (~0 & x).
This bug can be avoided if the return value of pcie_capability_read_word
is checked to confirm success.
Check the return value of pcie_capability_read_word() to ensure success.
Suggested-by: Bjorn Helgaas <bjorn@helgaas.com>
Signed-off-by: Bolarinwa Olayemi Saheed <refactormyself@gmail.com>
---
drivers/pci/pcie/aer.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
index 3acf56683915..f4beb47c622c 100644
--- a/drivers/pci/pcie/aer.c
+++ b/drivers/pci/pcie/aer.c
@@ -800,6 +800,7 @@ static bool is_error_source(struct pci_dev *dev, struct aer_err_info *e_info)
int aer = dev->aer_cap;
u32 status, mask;
u16 reg16;
+ int ret;
/*
* When bus id is equal to 0, it might be a bad id
@@ -828,8 +829,8 @@ static bool is_error_source(struct pci_dev *dev, struct aer_err_info *e_info)
return false;
/* Check if AER is enabled */
- pcie_capability_read_word(dev, PCI_EXP_DEVCTL, ®16);
- if (!(reg16 & PCI_EXP_AER_FLAGS))
+ ret = pcie_capability_read_word(dev, PCI_EXP_DEVCTL, ®16);
+ if (ret || !(reg16 & PCI_EXP_AER_FLAGS))
return false;
if (!aer)
--
2.18.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 8/14 v3] PCI/ACPI: Check the return value of pcie_capability_read_*()
2020-07-13 17:55 ` [PATCH 8/14 v3] PCI/ACPI: " Saheed O. Bolarinwa
@ 2020-07-14 13:27 ` Rafael J. Wysocki
0 siblings, 0 replies; 7+ messages in thread
From: Rafael J. Wysocki @ 2020-07-14 13:27 UTC (permalink / raw)
To: Saheed O. Bolarinwa
Cc: Shuah Khan, ACPI Devel Maling List, Linux PCI,
linux-kernel-mentees, Linux Kernel Mailing List
On Mon, Jul 13, 2020 at 6:55 PM Saheed O. Bolarinwa
<refactormyself@gmail.com> wrote:
>
> From: Bolarinwa Olayemi Saheed <refactormyself@gmail.com>
>
> On failure pcie_capability_read_dword() sets it's last parameter,
> val to 0.
> However, with Patch 14/14, it is possible that val is set to ~0 on
> failure. This would introduce a bug because (x & x) == (~0 & x).
>
> This bug can be avoided if the return value of pcie_capability_read_word
> is checked to confirm success.
>
> Check the return value of pcie_capability_read_word() to ensure success.
>
> Suggested-by: Bjorn Helgaas <bjorn@helgaas.com>
> Signed-off-by: Bolarinwa Olayemi Saheed <refactormyself@gmail.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
> drivers/pci/pci-acpi.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
> index 7224b1e5f2a8..39eb816bc3b8 100644
> --- a/drivers/pci/pci-acpi.c
> +++ b/drivers/pci/pci-acpi.c
> @@ -248,12 +248,13 @@ static bool pcie_root_rcb_set(struct pci_dev *dev)
> {
> struct pci_dev *rp = pcie_find_root_port(dev);
> u16 lnkctl;
> + int ret;
>
> if (!rp)
> return false;
>
> - pcie_capability_read_word(rp, PCI_EXP_LNKCTL, &lnkctl);
> - if (lnkctl & PCI_EXP_LNKCTL_RCB)
> + ret = pcie_capability_read_word(rp, PCI_EXP_LNKCTL, &lnkctl);
> + if (!ret && (lnkctl & PCI_EXP_LNKCTL_RCB))
> return true;
>
> return false;
> @@ -792,12 +793,13 @@ bool pciehp_is_native(struct pci_dev *bridge)
> {
> const struct pci_host_bridge *host;
> u32 slot_cap;
> + int ret;
>
> if (!IS_ENABLED(CONFIG_HOTPLUG_PCI_PCIE))
> return false;
>
> - pcie_capability_read_dword(bridge, PCI_EXP_SLTCAP, &slot_cap);
> - if (!(slot_cap & PCI_EXP_SLTCAP_HPC))
> + ret = pcie_capability_read_dword(bridge, PCI_EXP_SLTCAP, &slot_cap);
> + if (ret || !(slot_cap & PCI_EXP_SLTCAP_HPC))
> return false;
>
> if (pcie_ports_native)
> --
> 2.18.2
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 4/14 v3] iwlegacy: Check the return value of pcie_capability_read_*()
2020-07-13 17:55 ` [PATCH 4/14 v3] iwlegacy: " Saheed O. Bolarinwa
@ 2020-07-15 16:47 ` Kalle Valo
0 siblings, 0 replies; 7+ messages in thread
From: Kalle Valo @ 2020-07-15 16:47 UTC (permalink / raw)
To: Saheed O. Bolarinwa
Cc: skhan, linux-pci, linux-kernel-mentees, linux-kernel,
Stanislaw Gruszka, linux-wireless, netdev,
Bolarinwa Olayemi Saheed
"Saheed O. Bolarinwa" <refactormyself@gmail.com> wrote:
> From: Bolarinwa Olayemi Saheed <refactormyself@gmail.com>
>
> On failure pcie_capability_read_dword() sets it's last parameter, val
> to 0. However, with Patch 14/14, it is possible that val is set to ~0 on
> failure. This would introduce a bug because (x & x) == (~0 & x).
>
> This bug can be avoided without changing the function's behaviour if the
> return value of pcie_capability_read_dword is checked to confirm success.
>
> Check the return value of pcie_capability_read_dword() to ensure success.
>
> Suggested-by: Bjorn Helgaas <bjorn@helgaas.com>
> Signed-off-by: Bolarinwa Olayemi Saheed <refactormyself@gmail.com>
Patch applied to wireless-drivers-next.git, thanks.
9018fd7f2a73 iwlegacy: Check the return value of pcie_capability_read_*()
--
https://patchwork.kernel.org/patch/11660739/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 3/14 v3] ath9k: Check the return value of pcie_capability_read_*()
2020-07-13 17:55 ` [PATCH 3/14 v3] ath9k: Check the return value of pcie_capability_read_*() Saheed O. Bolarinwa
@ 2020-07-20 17:09 ` Kalle Valo
0 siblings, 0 replies; 7+ messages in thread
From: Kalle Valo @ 2020-07-20 17:09 UTC (permalink / raw)
To: Saheed O. Bolarinwa
Cc: skhan, linux-pci, linux-kernel-mentees, linux-kernel,
QCA ath9k Development, linux-wireless, netdev,
Bolarinwa Olayemi Saheed
"Saheed O. Bolarinwa" <refactormyself@gmail.com> wrote:
> On failure pcie_capability_read_dword() sets it's last parameter, val
> to 0. However, with Patch 14/14, it is possible that val is set to ~0 on
> failure. This would introduce a bug because (x & x) == (~0 & x).
>
> This bug can be avoided without changing the function's behaviour if the
> return value of pcie_capability_read_dword is checked to confirm success.
>
> Check the return value of pcie_capability_read_dword() to ensure success.
>
> Suggested-by: Bjorn Helgaas <bjorn@helgaas.com>
> Signed-off-by: Bolarinwa Olayemi Saheed <refactormyself@gmail.com>
> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Patch applied to ath-next branch of ath.git, thanks.
9a8ab2bfb678 ath9k: Check the return value of pcie_capability_read_*()
--
https://patchwork.kernel.org/patch/11660731/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2020-07-20 17:10 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20200713175529.29715-1-refactormyself@gmail.com>
2020-07-13 17:55 ` [PATCH 3/14 v3] ath9k: Check the return value of pcie_capability_read_*() Saheed O. Bolarinwa
2020-07-20 17:09 ` Kalle Valo
2020-07-13 17:55 ` [PATCH 4/14 v3] iwlegacy: " Saheed O. Bolarinwa
2020-07-15 16:47 ` Kalle Valo
2020-07-13 17:55 ` [PATCH 8/14 v3] PCI/ACPI: " Saheed O. Bolarinwa
2020-07-14 13:27 ` Rafael J. Wysocki
2020-07-13 17:55 ` [PATCH 12/14 v3] PCI/AER: " Saheed O. Bolarinwa
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).