IB/mlx5: Avoid async events on invalid port number
authorEli Cohen <eli@mellanox.com>
Wed, 11 Sep 2013 13:35:27 +0000 (16:35 +0300)
committerRoland Dreier <roland@purestorage.com>
Thu, 10 Oct 2013 16:23:57 +0000 (09:23 -0700)
On a single ported Connect-IB, its possible for the firmware to issue
events on the non-existing 2nd port.  Make sure to ignore events
generated for such ports.

Signed-off-by: Eli Cohen <eli@mellanox.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
drivers/infiniband/hw/mlx5/main.c

index 3f831de9a4d8a901607afc26c81827cc5c1e3bd5..e59761ed7d0066f92b1d89e16bdd607dc7e5f8f6 100644 (file)
@@ -1006,6 +1006,11 @@ static void mlx5_ib_event(struct mlx5_core_dev *dev, enum mlx5_dev_event event,
        ibev.device           = &ibdev->ib_dev;
        ibev.element.port_num = port;
 
+       if (port < 1 || port > ibdev->num_ports) {
+               mlx5_ib_warn(ibdev, "warning: event on port %d\n", port);
+               return;
+       }
+
        if (ibdev->ib_active)
                ib_dispatch_event(&ibev);
 }