Skip to content

Commit fd80bd7

Browse files
Kamalheibrleon
authored andcommitted
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: 2075bbe ("RDMA/ionic: Register device ops for miscellaneous functionality") Signed-off-by: Kamal Heib <kheib@redhat.com> Link: https://patch.msgid.link/20260220222125.16973-2-kheib@redhat.com Signed-off-by: Leon Romanovsky <leon@kernel.org>
1 parent 3d2e5d1 commit fd80bd7

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

drivers/infiniband/hw/ionic/ionic_ibdev.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ static int ionic_query_port(struct ib_device *ibdev, u32 port,
8181
return -EINVAL;
8282

8383
ndev = ib_device_get_netdev(ibdev, port);
84+
if (!ndev)
85+
return -ENODEV;
8486

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

0 commit comments

Comments
 (0)