summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorKarsten Graul <kgraul@linux.ibm.com>2022-04-08 17:10:34 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-04-20 09:23:14 +0200
commit35b91e49bc80ca944a8679c3b139ddaf2f8eea0f (patch)
treed0f937c3bb433d27299eb250ddc4cc7595133fa5 /net
parent98a7f6c4ada4ca97fcb0d508e097f8597df19d4d (diff)
downloadlinux-35b91e49bc80ca944a8679c3b139ddaf2f8eea0f.tar.gz
linux-35b91e49bc80ca944a8679c3b139ddaf2f8eea0f.tar.bz2
linux-35b91e49bc80ca944a8679c3b139ddaf2f8eea0f.zip
net/smc: Fix NULL pointer dereference in smc_pnet_find_ib()
[ Upstream commit d22f4f977236f97e01255a80bca2ea93a8094fc8 ] dev_name() was called with dev.parent as argument but without to NULL-check it before. Solve this by checking the pointer before the call to dev_name(). Fixes: af5f60c7e3d5 ("net/smc: allow PCI IDs as ib device names in the pnet table") Reported-by: syzbot+03e3e228510223dabd34@syzkaller.appspotmail.com Signed-off-by: Karsten Graul <kgraul@linux.ibm.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'net')
-rw-r--r--net/smc/smc_pnet.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/net/smc/smc_pnet.c b/net/smc/smc_pnet.c
index 9007c7e3bae4..30bae60d626c 100644
--- a/net/smc/smc_pnet.c
+++ b/net/smc/smc_pnet.c
@@ -310,8 +310,9 @@ static struct smc_ib_device *smc_pnet_find_ib(char *ib_name)
list_for_each_entry(ibdev, &smc_ib_devices.list, list) {
if (!strncmp(ibdev->ibdev->name, ib_name,
sizeof(ibdev->ibdev->name)) ||
- !strncmp(dev_name(ibdev->ibdev->dev.parent), ib_name,
- IB_DEVICE_NAME_MAX - 1)) {
+ (ibdev->ibdev->dev.parent &&
+ !strncmp(dev_name(ibdev->ibdev->dev.parent), ib_name,
+ IB_DEVICE_NAME_MAX - 1))) {
goto out;
}
}