[Linux-kernel-mentees] [PATCH 2/13] misc: rtsx: Check the return value of pcie_capability_read_*()

Greg Kroah-Hartman gregkh at linuxfoundation.org
Wed Jul 8 06:53:30 UTC 2020


On Wed, Jul 08, 2020 at 12:03:13AM +0200, Saheed Olayemi Bolarinwa wrote:
> From: Bolarinwa Olayemi Saheed <refactormyself at gmail.com>
> 
> 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 at helgaas.com>
> Signed-off-by: Bolarinwa Olayemi Saheed <refactormyself at gmail.com>

Acked-by: Greg Kroah-Hartman <gregkh at linuxfoundation.org>


More information about the Linux-kernel-mentees mailing list