* [PATCH] PCI: brcmstb: Add missing if statement
@ 2020-09-21 20:45 Alex Dewar
2020-09-21 20:56 ` Jim Quinlan
0 siblings, 1 reply; 5+ messages in thread
From: Alex Dewar @ 2020-09-21 20:45 UTC (permalink / raw)
Cc: Alex Dewar, Nicolas Saenz Julienne, Lorenzo Pieralisi,
Rob Herring, Bjorn Helgaas, Florian Fainelli,
bcm-kernel-feedback-list, Jim Quinlan, linux-rpi-kernel,
linux-arm-kernel, linux-pci, linux-kernel
brcm_pcie_resume() contains a return statement that was presumably
intended to have an "if (ret)" in front of it, otherwise the function
returns prematurely. Fix this.
I don't know if this code was tested or not, but I assume that this bug
means that this driver will not resume properly.
Fixes: ad3d29c77e1e ("PCI: brcmstb: Add control of rescal reset")
Addresses-Coverity: CID 1497099: Control flow issues (UNREACHABLE)
Signed-off-by: Alex Dewar <a.dewar@sussex.ac.uk>
---
drivers/pci/controller/pcie-brcmstb.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c
index 7a3ff4632e7c..cb0c11b7308e 100644
--- a/drivers/pci/controller/pcie-brcmstb.c
+++ b/drivers/pci/controller/pcie-brcmstb.c
@@ -1154,6 +1154,7 @@ static int brcm_pcie_resume(struct device *dev)
clk_prepare_enable(pcie->clk);
ret = brcm_phy_start(pcie);
+ if (ret)
return ret;
/* Take bridge out of reset so we can access the SERDES reg */
--
2.28.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] PCI: brcmstb: Add missing if statement
2020-09-21 20:45 [PATCH] PCI: brcmstb: Add missing if statement Alex Dewar
@ 2020-09-21 20:56 ` Jim Quinlan
2020-09-21 21:16 ` [PATCH v2] PCI: brcmstb: Add missing if statement and error path Alex Dewar
0 siblings, 1 reply; 5+ messages in thread
From: Jim Quinlan @ 2020-09-21 20:56 UTC (permalink / raw)
To: Alex Dewar
Cc: Alex Dewar, Nicolas Saenz Julienne, Lorenzo Pieralisi,
Rob Herring, Bjorn Helgaas, Florian Fainelli,
maintainer:BROADCOM BCM7XXX ARM ARCHITECTURE, Jim Quinlan,
moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE,
moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE,
open list:PCI NATIVE HOST BRIDGE AND ENDPOINT DRIVERS, open list
[-- Attachment #1: Type: text/plain, Size: 1429 bytes --]
On Mon, Sep 21, 2020 at 4:45 PM Alex Dewar <alex.dewar90@gmail.com> wrote:
>
> brcm_pcie_resume() contains a return statement that was presumably
> intended to have an "if (ret)" in front of it, otherwise the function
> returns prematurely. Fix this.
>
> I don't know if this code was tested or not, but I assume that this bug
> means that this driver will not resume properly.
>
> Fixes: ad3d29c77e1e ("PCI: brcmstb: Add control of rescal reset")
> Addresses-Coverity: CID 1497099: Control flow issues (UNREACHABLE)
> Signed-off-by: Alex Dewar <a.dewar@sussex.ac.uk>
> ---
> drivers/pci/controller/pcie-brcmstb.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c
> index 7a3ff4632e7c..cb0c11b7308e 100644
> --- a/drivers/pci/controller/pcie-brcmstb.c
> +++ b/drivers/pci/controller/pcie-brcmstb.c
> @@ -1154,6 +1154,7 @@ static int brcm_pcie_resume(struct device *dev)
> clk_prepare_enable(pcie->clk);
>
> ret = brcm_phy_start(pcie);
> + if (ret)
Hello,
Florian suggested adding braces to the if clause and inserting a
"clk_disable_unprepare(-cie->clk);" before the return. I am fine with
either what you have or implementing Florian's additional suggestion.
Thank you,
Jim Quinlan
Broadcom STB
> return ret;
>
> /* Take bridge out of reset so we can access the SERDES reg */
> --
> 2.28.0
>
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4167 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2] PCI: brcmstb: Add missing if statement and error path
2020-09-21 20:56 ` Jim Quinlan
@ 2020-09-21 21:16 ` Alex Dewar
2020-09-21 21:21 ` Florian Fainelli
2020-09-23 8:20 ` Lorenzo Pieralisi
0 siblings, 2 replies; 5+ messages in thread
From: Alex Dewar @ 2020-09-21 21:16 UTC (permalink / raw)
Cc: Alex Dewar, Nicolas Saenz Julienne, Lorenzo Pieralisi,
Rob Herring, Bjorn Helgaas, Florian Fainelli,
bcm-kernel-feedback-list, Jim Quinlan, linux-rpi-kernel,
linux-arm-kernel, linux-pci, linux-kernel
brcm_pcie_resume() contains a return statement that was presumably
intended to have an "if (ret)" in front of it, otherwise the function
returns prematurely. Fix this.
Additionally, redisable the clock on the error path.
I don't know if this code was tested or not, but I assume that this bug
means that this driver will not resume properly.
Fixes: ad3d29c77e1e ("PCI: brcmstb: Add control of rescal reset")
Addresses-Coverity: CID 1497099: Control flow issues (UNREACHABLE)
Signed-off-by: Alex Dewar <alex.dewar90@gmail.com>
---
Hi Jim,
Here's a new version of the patch.
I added the missing clk_disable_unprepare() and assumed that it would
also be required in the case that the call to brcm_pcie_setup() fails.
I didn't follow the suggestion of adding extra braces to the
if-statement as the kernel style is not to add unnecessary braces in
this case: https://www.kernel.org/doc/html/latest/process/coding-style.html?highlight=style#placing-braces-and-spaces
Best,
Alex
drivers/pci/controller/pcie-brcmstb.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c
index 7a3ff4632e7c..8bae3a4f8e49 100644
--- a/drivers/pci/controller/pcie-brcmstb.c
+++ b/drivers/pci/controller/pcie-brcmstb.c
@@ -1154,7 +1154,8 @@ static int brcm_pcie_resume(struct device *dev)
clk_prepare_enable(pcie->clk);
ret = brcm_phy_start(pcie);
- return ret;
+ if (ret)
+ goto err;
/* Take bridge out of reset so we can access the SERDES reg */
pcie->bridge_sw_init_set(pcie, 0);
@@ -1169,12 +1170,16 @@ static int brcm_pcie_resume(struct device *dev)
ret = brcm_pcie_setup(pcie);
if (ret)
- return ret;
+ goto err;
if (pcie->msi)
brcm_msi_set_regs(pcie->msi);
return 0;
+
+err:
+ clk_disable_unprepare(pcie->clk);
+ return ret;
}
static void __brcm_pcie_remove(struct brcm_pcie *pcie)
--
2.28.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] PCI: brcmstb: Add missing if statement and error path
2020-09-21 21:16 ` [PATCH v2] PCI: brcmstb: Add missing if statement and error path Alex Dewar
@ 2020-09-21 21:21 ` Florian Fainelli
2020-09-23 8:20 ` Lorenzo Pieralisi
1 sibling, 0 replies; 5+ messages in thread
From: Florian Fainelli @ 2020-09-21 21:21 UTC (permalink / raw)
To: Alex Dewar
Cc: Nicolas Saenz Julienne, Lorenzo Pieralisi, Rob Herring,
Bjorn Helgaas, Florian Fainelli, bcm-kernel-feedback-list,
Jim Quinlan, linux-rpi-kernel, linux-arm-kernel, linux-pci,
linux-kernel
On 9/21/20 2:16 PM, Alex Dewar wrote:
> brcm_pcie_resume() contains a return statement that was presumably
> intended to have an "if (ret)" in front of it, otherwise the function
> returns prematurely. Fix this.
>
> Additionally, redisable the clock on the error path.
>
> I don't know if this code was tested or not, but I assume that this bug
> means that this driver will not resume properly.
>
> Fixes: ad3d29c77e1e ("PCI: brcmstb: Add control of rescal reset")
> Addresses-Coverity: CID 1497099: Control flow issues (UNREACHABLE)
> Signed-off-by: Alex Dewar <alex.dewar90@gmail.com>
> ---
You need to coordinate with Colin, or with whomever is looking at
Coverity defects, because he just submitted a similar patch minutes ago:
https://lore.kernel.org/linux-arm-kernel/20200921211555.383458-1-colin.king@canonical.com/
--
Florian
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] PCI: brcmstb: Add missing if statement and error path
2020-09-21 21:16 ` [PATCH v2] PCI: brcmstb: Add missing if statement and error path Alex Dewar
2020-09-21 21:21 ` Florian Fainelli
@ 2020-09-23 8:20 ` Lorenzo Pieralisi
1 sibling, 0 replies; 5+ messages in thread
From: Lorenzo Pieralisi @ 2020-09-23 8:20 UTC (permalink / raw)
To: Alex Dewar
Cc: Nicolas Saenz Julienne, Rob Herring, Bjorn Helgaas,
Florian Fainelli, bcm-kernel-feedback-list, Jim Quinlan,
linux-rpi-kernel, linux-arm-kernel, linux-pci, linux-kernel
On Mon, Sep 21, 2020 at 10:16:24PM +0100, Alex Dewar wrote:
> brcm_pcie_resume() contains a return statement that was presumably
> intended to have an "if (ret)" in front of it, otherwise the function
> returns prematurely. Fix this.
>
> Additionally, redisable the clock on the error path.
>
> I don't know if this code was tested or not, but I assume that this bug
> means that this driver will not resume properly.
>
> Fixes: ad3d29c77e1e ("PCI: brcmstb: Add control of rescal reset")
> Addresses-Coverity: CID 1497099: Control flow issues (UNREACHABLE)
> Signed-off-by: Alex Dewar <alex.dewar90@gmail.com>
> ---
> Hi Jim,
>
> Here's a new version of the patch.
>
> I added the missing clk_disable_unprepare() and assumed that it would
> also be required in the case that the call to brcm_pcie_setup() fails.
>
> I didn't follow the suggestion of adding extra braces to the
> if-statement as the kernel style is not to add unnecessary braces in
> this case: https://www.kernel.org/doc/html/latest/process/coding-style.html?highlight=style#placing-braces-and-spaces
>
> Best,
> Alex
>
> drivers/pci/controller/pcie-brcmstb.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
Squashed in the original patch, pushed out in my pci/brcmstb branch,
I will drop Colin's patch following this discussion. If there is
any issue please shout, thanks.
Lorenzo
> diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c
> index 7a3ff4632e7c..8bae3a4f8e49 100644
> --- a/drivers/pci/controller/pcie-brcmstb.c
> +++ b/drivers/pci/controller/pcie-brcmstb.c
> @@ -1154,7 +1154,8 @@ static int brcm_pcie_resume(struct device *dev)
> clk_prepare_enable(pcie->clk);
>
> ret = brcm_phy_start(pcie);
> - return ret;
> + if (ret)
> + goto err;
>
> /* Take bridge out of reset so we can access the SERDES reg */
> pcie->bridge_sw_init_set(pcie, 0);
> @@ -1169,12 +1170,16 @@ static int brcm_pcie_resume(struct device *dev)
>
> ret = brcm_pcie_setup(pcie);
> if (ret)
> - return ret;
> + goto err;
>
> if (pcie->msi)
> brcm_msi_set_regs(pcie->msi);
>
> return 0;
> +
> +err:
> + clk_disable_unprepare(pcie->clk);
> + return ret;
> }
>
> static void __brcm_pcie_remove(struct brcm_pcie *pcie)
> --
> 2.28.0
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-09-23 8:20 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-21 20:45 [PATCH] PCI: brcmstb: Add missing if statement Alex Dewar
2020-09-21 20:56 ` Jim Quinlan
2020-09-21 21:16 ` [PATCH v2] PCI: brcmstb: Add missing if statement and error path Alex Dewar
2020-09-21 21:21 ` Florian Fainelli
2020-09-23 8:20 ` Lorenzo Pieralisi
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).