]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-client.git/commitdiff
RDMA/ionic: Fix potential NULL pointer dereference in ionic_query_port
authorKamal Heib <kheib@redhat.com>
Fri, 20 Feb 2026 22:21:26 +0000 (17:21 -0500)
committerLeon Romanovsky <leon@kernel.org>
Tue, 24 Feb 2026 09:54:10 +0000 (04:54 -0500)
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: 2075bbe8ef03 ("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>
drivers/infiniband/hw/ionic/ionic_ibdev.c

index 164046d00e5d47d2cc8ad2d9f44d5fc95178d031..bd4c73e530d08109c988f3740eb54da931dadc29 100644 (file)
@@ -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;