diff options
author | Moni Shoua <monis@mellanox.com> | 2014-08-21 07:28:37 -0400 |
---|---|---|
committer | Roland Dreier <roland@purestorage.com> | 2014-09-22 12:46:52 -0400 |
commit | e381835cf1b8e3b2857277dbc3b77d8c5350f70a (patch) | |
tree | 5fdd73c629fe7753fbd4c5b29317df7b96ee9e20 /drivers/infiniband | |
parent | 4ff0acca7344c93fd9ed778b4c3ce16d95c594e4 (diff) |
IB/mlx4: Avoid null pointer dereference in mlx4_ib_scan_netdevs()
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: ad4885d279b6 ("IB/mlx4: Build the port IBoE GID table properly under bonding")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Moni Shoua <monis@mellanox.com>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r-- | drivers/infiniband/hw/mlx4/main.c | 49 |
1 files changed, 26 insertions, 23 deletions
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c index 20f731f08c7e..bf09d79afd4d 100644 --- a/drivers/infiniband/hw/mlx4/main.c +++ b/drivers/infiniband/hw/mlx4/main.c | |||
@@ -1789,31 +1789,34 @@ static void mlx4_ib_scan_netdevs(struct mlx4_ib_dev *ibdev, | |||
1789 | port_state = (netif_running(curr_netdev) && netif_carrier_ok(curr_netdev)) ? | 1789 | port_state = (netif_running(curr_netdev) && netif_carrier_ok(curr_netdev)) ? |
1790 | IB_PORT_ACTIVE : IB_PORT_DOWN; | 1790 | IB_PORT_ACTIVE : IB_PORT_DOWN; |
1791 | mlx4_ib_set_default_gid(ibdev, curr_netdev, port); | 1791 | mlx4_ib_set_default_gid(ibdev, curr_netdev, port); |
1792 | } else { | 1792 | /* if using bonding/team and a slave port is down, we |
1793 | reset_gid_table(ibdev, port); | 1793 | * don't the bond IP based gids in the table since |
1794 | } | 1794 | * flows that select port by gid may get the down port. |
1795 | /* if using bonding/team and a slave port is down, we don't the bond IP | 1795 | */ |
1796 | * based gids in the table since flows that select port by gid may get | 1796 | if (curr_master && (port_state == IB_PORT_DOWN)) { |
1797 | * the down port. | 1797 | reset_gid_table(ibdev, port); |
1798 | */ | 1798 | mlx4_ib_set_default_gid(ibdev, |
1799 | if (curr_master && (port_state == IB_PORT_DOWN)) { | 1799 | curr_netdev, port); |
1800 | reset_gid_table(ibdev, port); | 1800 | } |
1801 | mlx4_ib_set_default_gid(ibdev, curr_netdev, port); | 1801 | /* if bonding is used it is possible that we add it to |
1802 | } | 1802 | * masters only after IP address is assigned to the |
1803 | /* if bonding is used it is possible that we add it to masters | 1803 | * net bonding interface. |
1804 | * only after IP address is assigned to the net bonding | 1804 | */ |
1805 | * interface. | 1805 | if (curr_master && (old_master != curr_master)) { |
1806 | */ | 1806 | reset_gid_table(ibdev, port); |
1807 | if (curr_master && (old_master != curr_master)) { | 1807 | mlx4_ib_set_default_gid(ibdev, |
1808 | reset_gid_table(ibdev, port); | 1808 | curr_netdev, port); |
1809 | mlx4_ib_set_default_gid(ibdev, curr_netdev, port); | 1809 | mlx4_ib_get_dev_addr(curr_master, ibdev, port); |
1810 | mlx4_ib_get_dev_addr(curr_master, ibdev, port); | 1810 | } |
1811 | } | ||
1812 | 1811 | ||
1813 | if (!curr_master && (old_master != curr_master)) { | 1812 | if (!curr_master && (old_master != curr_master)) { |
1813 | reset_gid_table(ibdev, port); | ||
1814 | mlx4_ib_set_default_gid(ibdev, | ||
1815 | curr_netdev, port); | ||
1816 | mlx4_ib_get_dev_addr(curr_netdev, ibdev, port); | ||
1817 | } | ||
1818 | } else { | ||
1814 | reset_gid_table(ibdev, port); | 1819 | reset_gid_table(ibdev, port); |
1815 | mlx4_ib_set_default_gid(ibdev, curr_netdev, port); | ||
1816 | mlx4_ib_get_dev_addr(curr_netdev, ibdev, port); | ||
1817 | } | 1820 | } |
1818 | } | 1821 | } |
1819 | 1822 | ||