Commit 23636720 authored by Moni Shoua's avatar Moni Shoua Committed by Greg Kroah-Hartman

IB/mlx4: Avoid null pointer dereference in mlx4_ib_scan_netdevs()

commit e381835c upstream.

When Ethernet netdev is not present for a port (e.g. when the link
layer type of the port is InfiniBand) it's possible to dereference a
null pointer when we do netdevice scanning.

To fix that, we move a section of code that needs to run only when
netdev is present to a proper if () statement.

Fixes: ad4885d2 ("IB/mlx4: Build the port IBoE GID table properly under bonding")
Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarMoni Shoua <monis@mellanox.com>
Signed-off-by: default avatarOr Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: default avatarRoland Dreier <roland@purestorage.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent f59c9cae
...@@ -1788,31 +1788,34 @@ static void mlx4_ib_scan_netdevs(struct mlx4_ib_dev *ibdev, ...@@ -1788,31 +1788,34 @@ static void mlx4_ib_scan_netdevs(struct mlx4_ib_dev *ibdev,
port_state = (netif_running(curr_netdev) && netif_carrier_ok(curr_netdev)) ? port_state = (netif_running(curr_netdev) && netif_carrier_ok(curr_netdev)) ?
IB_PORT_ACTIVE : IB_PORT_DOWN; IB_PORT_ACTIVE : IB_PORT_DOWN;
mlx4_ib_set_default_gid(ibdev, curr_netdev, port); mlx4_ib_set_default_gid(ibdev, curr_netdev, port);
} else { /* if using bonding/team and a slave port is down, we
reset_gid_table(ibdev, port); * don't the bond IP based gids in the table since
} * flows that select port by gid may get the down port.
/* if using bonding/team and a slave port is down, we don't the bond IP */
* based gids in the table since flows that select port by gid may get if (curr_master && (port_state == IB_PORT_DOWN)) {
* the down port. reset_gid_table(ibdev, port);
*/ mlx4_ib_set_default_gid(ibdev,
if (curr_master && (port_state == IB_PORT_DOWN)) { curr_netdev, port);
reset_gid_table(ibdev, port); }
mlx4_ib_set_default_gid(ibdev, curr_netdev, port); /* if bonding is used it is possible that we add it to
} * masters only after IP address is assigned to the
/* if bonding is used it is possible that we add it to masters * net bonding interface.
* only after IP address is assigned to the net bonding */
* interface. if (curr_master && (old_master != curr_master)) {
*/ reset_gid_table(ibdev, port);
if (curr_master && (old_master != curr_master)) { mlx4_ib_set_default_gid(ibdev,
reset_gid_table(ibdev, port); curr_netdev, port);
mlx4_ib_set_default_gid(ibdev, curr_netdev, port); mlx4_ib_get_dev_addr(curr_master, ibdev, port);
mlx4_ib_get_dev_addr(curr_master, ibdev, port); }
}
if (!curr_master && (old_master != curr_master)) { if (!curr_master && (old_master != curr_master)) {
reset_gid_table(ibdev, port);
mlx4_ib_set_default_gid(ibdev,
curr_netdev, port);
mlx4_ib_get_dev_addr(curr_netdev, ibdev, port);
}
} else {
reset_gid_table(ibdev, port); reset_gid_table(ibdev, port);
mlx4_ib_set_default_gid(ibdev, curr_netdev, port);
mlx4_ib_get_dev_addr(curr_netdev, ibdev, port);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment