Skip to content

Commit d22f4f9

Browse files
karstengrkuba-moo
authored andcommitted
net/smc: Fix NULL pointer dereference in smc_pnet_find_ib()
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: af5f60c ("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>
1 parent b1871fd commit d22f4f9

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

net/smc/smc_pnet.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,9 @@ static struct smc_ib_device *smc_pnet_find_ib(char *ib_name)
311311
list_for_each_entry(ibdev, &smc_ib_devices.list, list) {
312312
if (!strncmp(ibdev->ibdev->name, ib_name,
313313
sizeof(ibdev->ibdev->name)) ||
314-
!strncmp(dev_name(ibdev->ibdev->dev.parent), ib_name,
315-
IB_DEVICE_NAME_MAX - 1)) {
314+
(ibdev->ibdev->dev.parent &&
315+
!strncmp(dev_name(ibdev->ibdev->dev.parent), ib_name,
316+
IB_DEVICE_NAME_MAX - 1))) {
316317
goto out;
317318
}
318319
}

0 commit comments

Comments
 (0)