Skip to content

Commit

Permalink
thunderbolt: Check return value of tb_sw_read() in usb4_switch_op()
Browse files Browse the repository at this point in the history
The function misses checking return value of tb_sw_read() before it
accesses the value that was read. Fix this by checking the return value
first.

Fixes: b040798 ("thunderbolt: Add initial support for USB4")
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Yehezkel Bernat <yehezkelshb@gmail.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Mika Westerberg authored and Greg Kroah-Hartman committed Apr 28, 2020
1 parent 6a8b55e commit c3bf993
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/thunderbolt/usb4.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ static int usb4_switch_op(struct tb_switch *sw, u16 opcode, u8 *status)
return ret;

ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, ROUTER_CS_26, 1);
if (ret)
return ret;

if (val & ROUTER_CS_26_ONS)
return -EOPNOTSUPP;

Expand Down

0 comments on commit c3bf993

Please sign in to comment.