iwlegacy: Check the return value of pcie_capability_read_*()
authorBolarinwa Olayemi Saheed <refactormyself@gmail.com>
Mon, 13 Jul 2020 17:55:27 +0000 (19:55 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 19 Aug 2020 06:23:40 +0000 (08:23 +0200)
commit3fbcad2f1bf0b2e886bfa7af26a2642272f8c9c5
tree6f08888722e431e705b465dd61a89a458fb2d7ff
parentbfcd172df8217a0e28260daa4a1089e2b129834a
iwlegacy: Check the return value of pcie_capability_read_*()

[ Upstream commit 9018fd7f2a73e9b290f48a56b421558fa31e8b75 ]

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>
Link: https://lore.kernel.org/r/20200713175529.29715-3-refactormyself@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/wireless/intel/iwlegacy/common.c