RDMA/ionic: Fix potential NULL pointer dereference in ionic_query_port
Subsystems (2)
PATCH 1/1 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 2075bbe8ef03 ("RDMA/ionic: Register device ops for miscellaneous functionality")
Signed-off-by Kamal Heib <[email protected]>
--- drivers/infiniband/hw/ionic/ionic_ibdev.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/infiniband/hw/ionic/ionic_ibdev.c +2 -0
@@ -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 ;
Signature · 1 line
2.52.0
Leon Romanovsky
AppliedQuoted 6 lines · Kamal Heib
The function
ionic_query_port()callsib_device_get_netdev()without checking the return value which could lead to NULL pointer dereference, Fix it by checking the return value and return-ENODEVif the 'ndev' is NULL.
Applied, thanks!
[1/1] RDMA/ionic: Fix potential NULL pointer dereference in ionic_query_port
https://git.kernel.org/rdma/rdma/c/fd80bd7105f881
Best regards,
Signature · 1 line
Leon Romanovsky <[email protected]>