* [PATCH] thunderbolt: Check return value of tb_sw_read() in usb4_switch_op()
@ 2020-04-16 12:01 Mika Westerberg
2020-04-16 23:20 ` Yehezkel Bernat
0 siblings, 1 reply; 3+ messages in thread
From: Mika Westerberg @ 2020-04-16 12:01 UTC (permalink / raw)
To: linux-usb
Cc: Yehezkel Bernat, Michael Jamet, Andreas Noever, Mika Westerberg,
Lukas Wunner
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: b04079837b20 ("thunderbolt: Add initial support for USB4")
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
drivers/thunderbolt/usb4.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/thunderbolt/usb4.c b/drivers/thunderbolt/usb4.c
index 3d084cec136f..50c7534ba31e 100644
--- a/drivers/thunderbolt/usb4.c
+++ b/drivers/thunderbolt/usb4.c
@@ -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;
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] thunderbolt: Check return value of tb_sw_read() in usb4_switch_op()
2020-04-16 12:01 [PATCH] thunderbolt: Check return value of tb_sw_read() in usb4_switch_op() Mika Westerberg
@ 2020-04-16 23:20 ` Yehezkel Bernat
2020-04-20 8:57 ` Mika Westerberg
0 siblings, 1 reply; 3+ messages in thread
From: Yehezkel Bernat @ 2020-04-16 23:20 UTC (permalink / raw)
To: Mika Westerberg; +Cc: linux-usb, Michael Jamet, Andreas Noever, Lukas Wunner
On Thu, Apr 16, 2020 at 3:01 PM Mika Westerberg
<mika.westerberg@linux.intel.com> wrote:
>
> 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: b04079837b20 ("thunderbolt: Add initial support for USB4")
> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Yehezkel Bernat <yehezkelshb@gmail.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] thunderbolt: Check return value of tb_sw_read() in usb4_switch_op()
2020-04-16 23:20 ` Yehezkel Bernat
@ 2020-04-20 8:57 ` Mika Westerberg
0 siblings, 0 replies; 3+ messages in thread
From: Mika Westerberg @ 2020-04-20 8:57 UTC (permalink / raw)
To: Yehezkel Bernat; +Cc: linux-usb, Michael Jamet, Andreas Noever, Lukas Wunner
On Fri, Apr 17, 2020 at 02:20:26AM +0300, Yehezkel Bernat wrote:
> On Thu, Apr 16, 2020 at 3:01 PM Mika Westerberg
> <mika.westerberg@linux.intel.com> wrote:
> >
> > 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: b04079837b20 ("thunderbolt: Add initial support for USB4")
> > Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
>
> Reviewed-by: Yehezkel Bernat <yehezkelshb@gmail.com>
Applied to fixes, thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-04-20 8:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-16 12:01 [PATCH] thunderbolt: Check return value of tb_sw_read() in usb4_switch_op() Mika Westerberg
2020-04-16 23:20 ` Yehezkel Bernat
2020-04-20 8:57 ` Mika Westerberg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).