提交 3d4ed656 编写于 作者: K Karsten Graul 提交者: Zheng Zengkai

net/smc: Fix NULL pointer dereference in smc_pnet_find_ib()

stable inclusion
from stable-v5.10.112
commit 35b91e49bc80ca944a8679c3b139ddaf2f8eea0f
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5HL0X

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=35b91e49bc80ca944a8679c3b139ddaf2f8eea0f

--------------------------------

[ Upstream commit d22f4f97 ]

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: af5f60c7 ("net/smc: allow PCI IDs as ib device names in the pnet table")
Reported-by: syzbot+03e3e228510223dabd34@syzkaller.appspotmail.com
Signed-off-by: NKarsten Graul <kgraul@linux.ibm.com>
Signed-off-by: NJakub Kicinski <kuba@kernel.org>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
上级 c06546a8
...@@ -310,8 +310,9 @@ static struct smc_ib_device *smc_pnet_find_ib(char *ib_name) ...@@ -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) { list_for_each_entry(ibdev, &smc_ib_devices.list, list) {
if (!strncmp(ibdev->ibdev->name, ib_name, if (!strncmp(ibdev->ibdev->name, ib_name,
sizeof(ibdev->ibdev->name)) || sizeof(ibdev->ibdev->name)) ||
!strncmp(dev_name(ibdev->ibdev->dev.parent), ib_name, (ibdev->ibdev->dev.parent &&
IB_DEVICE_NAME_MAX - 1)) { !strncmp(dev_name(ibdev->ibdev->dev.parent), ib_name,
IB_DEVICE_NAME_MAX - 1))) {
goto out; goto out;
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册