diff mbox series

thunderbolt: Fix error code in tb_port_is_width_supported()

Message ID 20200303101716.uf6l62oavfqmf6hm@kili.mountain (mailing list archive)
State Mainlined
Commit e9d0e7511fda92a6511904996dd0aa57b6d7687a
Headers show
Series thunderbolt: Fix error code in tb_port_is_width_supported() | expand

Commit Message

Dan Carpenter March 3, 2020, 10:17 a.m. UTC
This function is type bool, and it's supposed to return true on success. 
Unfortunately, this path takes negative error codes and casts them to
bool (true) so it's treated as success instead of failure.

Fixes: 91c0c12080d0 ("thunderbolt: Add support for lane bonding")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/thunderbolt/switch.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Mika Westerberg March 4, 2020, 9:38 a.m. UTC | #1
On Tue, Mar 03, 2020 at 01:17:16PM +0300, Dan Carpenter wrote:
> This function is type bool, and it's supposed to return true on success. 
> Unfortunately, this path takes negative error codes and casts them to
> bool (true) so it's treated as success instead of failure.
> 
> Fixes: 91c0c12080d0 ("thunderbolt: Add support for lane bonding")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Applied to fixes, thanks!
diff mbox series

Patch

diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c
index 7d6ecc342508..a2ce99051c51 100644
--- a/drivers/thunderbolt/switch.c
+++ b/drivers/thunderbolt/switch.c
@@ -954,7 +954,7 @@  static bool tb_port_is_width_supported(struct tb_port *port, int width)
 	ret = tb_port_read(port, &phy, TB_CFG_PORT,
 			   port->cap_phy + LANE_ADP_CS_0, 1);
 	if (ret)
-		return ret;
+		return false;
 
 	widths = (phy & LANE_ADP_CS_0_SUPPORTED_WIDTH_MASK) >>
 		LANE_ADP_CS_0_SUPPORTED_WIDTH_SHIFT;