RDMA/irdma: Fix potential NULL-ptr-dereference
authorNikita Zhandarovich <n.zhandarovich@fintech.ru>
Thu, 26 Jan 2023 18:52:30 +0000 (10:52 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 14 Feb 2023 18:17:58 +0000 (19:17 +0100)
commit8f5fe1cd8e6a97f94840b55f59ed08cbc397086f
tree140759904f07c96531d1a5c1f0294f0ee9c654a4
parent1b4ef90cbcfa603b3bb536fbd6f261197012b6f6
RDMA/irdma: Fix potential NULL-ptr-dereference

[ Upstream commit 5d9745cead1f121974322b94ceadfb4d1e67960e ]

in_dev_get() can return NULL which will cause a failure once idev is
dereferenced in in_dev_for_each_ifa_rtnl(). This patch adds a
check for NULL value in idev beforehand.

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

Fixes: 146b9756f14c ("RDMA/irdma: Add connection manager")
Signed-off-by: Nikita Zhandarovich <n.zhandarovich@fintech.ru>
Link: https://lore.kernel.org/r/20230126185230.62464-1-n.zhandarovich@fintech.ru
Reviewed-by: Sindhu Devale <sindhu.devale@intel.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/infiniband/hw/irdma/cm.c