Commit fd80bd71 authored by Kamal Heib's avatar Kamal Heib Committed by Leon Romanovsky
Browse files

RDMA/ionic: Fix potential NULL pointer dereference in ionic_query_port



The function ionic_query_port() calls ib_device_get_netdev() without
checking the return value which could lead to NULL pointer dereference,
Fix it by checking the return value and return -ENODEV if the 'ndev' is
NULL.

Fixes: 2075bbe8 ("RDMA/ionic: Register device ops for miscellaneous functionality")
Signed-off-by: default avatarKamal Heib <kheib@redhat.com>
Link: https://patch.msgid.link/20260220222125.16973-2-kheib@redhat.com


Signed-off-by: default avatarLeon Romanovsky <leon@kernel.org>
parent 3d2e5d12
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -81,6 +81,8 @@ static int ionic_query_port(struct ib_device *ibdev, u32 port,
		return -EINVAL;

	ndev = ib_device_get_netdev(ibdev, port);
	if (!ndev)
		return -ENODEV;

	if (netif_running(ndev) && netif_carrier_ok(ndev)) {
		attr->state = IB_PORT_ACTIVE;