mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] thunderbolt_tb: add check for return value of 'tb_switch_find_port'
@ 2023-02-17 13:24 Natalia Petrova
  2023-02-17 13:41 ` Mika Westerberg
  0 siblings, 1 reply; 2+ messages in thread
From: Natalia Petrova @ 2023-02-17 13:24 UTC (permalink / raw)
  To: Andreas Noever
  Cc: Natalia Petrova, Michael Jamet, Mika Westerberg, Yehezkel Bernat,
	linux-usb, linux-kernel, lvc-project

Return value of 'tb_switch_find_port' has to be checked to avoid
null pointer dereferences in functions tb_tunnel_alloc_dma() and
tb_port_info().

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 386e5e29d81c ("thunderbolt: Make tb_find_port() available to other files")
Signed-off-by: Natalia Petrova <n.petrova@fintech.ru>
---
 drivers/thunderbolt/tb.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c
index 9853f6c7e81d..5d6cded68d46 100644
--- a/drivers/thunderbolt/tb.c
+++ b/drivers/thunderbolt/tb.c
@@ -1156,6 +1156,8 @@ static int tb_approve_xdomain_paths(struct tb *tb, struct tb_xdomain *xd,
 	sw = tb_to_switch(xd->dev.parent);
 	dst_port = tb_port_at(xd->route, sw);
 	nhi_port = tb_switch_find_port(tb->root_switch, TB_TYPE_NHI);
+	if (!nhi_port)
+		return -EIO;
 
 	mutex_lock(&tb->lock);
 	tunnel = tb_tunnel_alloc_dma(tb, nhi_port, dst_port, transmit_path,
-- 
2.34.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-02-17 13:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-17 13:24 [PATCH] thunderbolt_tb: add check for return value of 'tb_switch_find_port' Natalia Petrova
2023-02-17 13:41 ` Mika Westerberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®