Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a05f5e26 authored by Karsten Graul's avatar Karsten Graul Committed by Greg Kroah-Hartman
Browse files

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: af5f60c7 ("net/smc: allow PCI IDs as ib device names in the pnet table")
Reported-by: default avatar <syzbot+03e3e228510223dabd34@syzkaller.appspotmail.com>
Signed-off-by: default avatarKarsten Graul <kgraul@linux.ibm.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 1ac7c6d7
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -295,8 +295,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)) ||
		    (ibdev->ibdev->dev.parent &&
		     !strncmp(dev_name(ibdev->ibdev->dev.parent), ib_name,
			     IB_DEVICE_NAME_MAX - 1)) {
			     IB_DEVICE_NAME_MAX - 1))) {
			goto out;
		}
	}