PCI: brcmstb: Correctly store and use the output value
Subsystems (5)
PATCH 1/1 PCI: brcmstb: Correctly store and use the output value
brcm_pcie_get_inbound_wins() can return negative error. As num_inbound_wins is unsigned, we'll be unable to recognize the error. Hence store return value of brcm_pcie_get_inbound_wins() in ret which is signed and store result back to num_inbound_wins after confirming that it isn't negative.
--- drivers/pci/controller/pcie-brcmstb.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/pci/controller/pcie-brcmstb.c +4 -3
@@ -1090,9 +1090,10 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie)u32p_replace_bits (&tmp,1 ,PCIE_MISC_MISC_CTRL_PCIE_RCB_64B_MODE_MASK );writel (tmp, base +PCIE_MISC_MISC_CTRL ); - num_inbound_wins =brcm_pcie_get_inbound_wins (pcie, inbound_wins); -if (num_inbound_wins <0 ) -return num_inbound_wins; + ret =brcm_pcie_get_inbound_wins (pcie, inbound_wins); +if (ret <0 ) +return ret; + num_inbound_wins = (u8 )ret;set_inbound_win_registers (pcie, inbound_wins, num_inbound_wins);
Signature · 1 line
2.39.2
Quoted 6 lines · Muhammad Usama Anjum
brcm_pcie_get_inbound_wins()can return negative error. Asnum_inbound_winsis unsigned, we'll be unable to recognize the error. Hence store return value ofbrcm_pcie_get_inbound_wins()in ret which is signed and store result back tonum_inbound_winsafter confirming that it isn't negative.
Hello Muhammad,
You are correct -- I was asked to make a few variables to be of the type u8, but I missed having an int (ret) hold the resultof that call. I believe I am still in the process of submitting this commit series -- V7 is coming next -- so I will
take your email as a review instead of adding a fixup commit.
Unless Bjorn says that V6 was applied.
Thanks and regards,
Jim Quinlan
Broadcom STB/CM
Quoted 29 lines
Fixes 46c981fd60de ("PCI: brcmstb: Refactor for chips with many regular inbound windows")Signed-off-by Muhammad Usama Anjum <[email protected]>--- drivers/pci/controller/pcie-brcmstb.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/pci/controller/pcie-brcmstb.c +4
-4@@ -1090,9 +1090,10 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie)u32p_replace_bits (&tmp,1 ,PCIE_MISC_MISC_CTRL_PCIE_RCB_64B_MODE_MASK );writel (tmp, base +PCIE_MISC_MISC_CTRL ); - num_inbound_wins =brcm_pcie_get_inbound_wins (pcie, inbound_wins); -if (num_inbound_wins <0 ) -return num_inbound_wins; + ret =brcm_pcie_get_inbound_wins (pcie, inbound_wins); +if (ret <0 ) +return ret; + num_inbound_wins = (u8 )ret;set_inbound_win_registers (pcie, inbound_wins, num_inbound_wins); --2.39.2
Florian Fainelli
maintainerQuoted 10 lines · Jim Quinlan
Quoted 6 lines · Muhammad Usama Anjum
brcm_pcie_get_inbound_wins()can return negative error. Asnum_inbound_winsis unsigned, we'll be unable to recognize the error. Hence store return value ofbrcm_pcie_get_inbound_wins()in ret which is signed and store result back tonum_inbound_winsafter confirming that it isn't negative.
Quoted 8 lines
Hello Muhammad,
You are correct -- I was asked to make a few variables to be of the type u8, but I missed having an int (ret) hold the resultof that call. I believe I am still in the process of submitting this commit series -- V7 is coming next -- so I will
take your email as a review instead of adding a fixup commit.Unless Bjorn says that V6 was applied.
A similar patch has already been submitted to address this in a slightly different way:
https://lore.kernel.org/all/[email protected]/
Signature · 1 line
Florian