RDMA/cxgb4: Fix potential null-ptr-deref in pass_establish()
authorNikita Zhandarovich <n.zhandarovich@fintech.ru>
Thu, 2 Feb 2023 18:48:50 +0000 (10:48 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 10 Mar 2023 08:39:41 +0000 (09:39 +0100)
commit9dca64042d855a24b0bd81ce242e5dc7e939f6eb
tree8974b2b1b8b57d039c34cdf4b0fa63cbe97ce223
parent16603bced2d1568dc8124bd1394f236c0f83c220
RDMA/cxgb4: Fix potential null-ptr-deref in pass_establish()

[ Upstream commit 283861a4c52c1ea4df3dd1b6fc75a50796ce3524 ]

If get_ep_from_tid() fails to lookup non-NULL value for ep, ep is
dereferenced later regardless of whether it is empty.
This patch adds a simple sanity check to fix the issue.

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

Fixes: 944661dd97f4 ("RDMA/iw_cxgb4: atomically lookup ep and get a reference")
Signed-off-by: Nikita Zhandarovich <n.zhandarovich@fintech.ru>
Link: https://lore.kernel.org/r/20230202184850.29882-1-n.zhandarovich@fintech.ru
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/infiniband/hw/cxgb4/cm.c