Re: [PATCH 2/13] misc: rtsx: Check the return value of pcie_capability_read_*()

From: Greg Kroah-Hartman
Date: Wed Jul 08 2020 - 02:53:36 EST


On Wed, Jul 08, 2020 at 12:03:13AM +0200, Saheed Olayemi Bolarinwa wrote:
> From: Bolarinwa Olayemi Saheed <refactormyself@xxxxxxxxx>
>
> On failure pcie_capability_read_dword() sets it's last parameter, val
> to 0. In which case (val & PCI_EXP_DEVCTL2_LTR_EN) evaluates to 0.
> However, with Patch 13/13, 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_word is checked to confirm success.
>
> Check the return value of pcie_capability_read_word() to ensure success.
>
> Suggested-by: Bjorn Helgaas <bjorn@xxxxxxxxxxx>
> Signed-off-by: Bolarinwa Olayemi Saheed <refactormyself@xxxxxxxxx>

Acked-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>