Skip to contentSkip to conversation

RDMA/ionic: Fix potential NULL pointer dereference in ionic_query_port

PATCH Applied Kamal Heib 2 participants 2 messages Feb 20 – Feb 24

Subsystems (2)
lore
Share & tools
lore

Kamal Heib

author
#0 lore raw

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")
---
 drivers/infiniband/hw/ionic/ionic_ibdev.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/infiniband/hw/ionic/ionic_ibdev.c +2 -0
index 164046d00e5d..bd4c73e530d0 100644
@@ -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
#1 lore raw
Quoted 6 lines · Kamal Heib

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.

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]>