IB/mlx4: Avoid null pointer dereference in mlx4_ib_scan_netdevs()
authorMoni Shoua <monis@mellanox.com>
Thu, 21 Aug 2014 11:28:37 +0000 (14:28 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 5 Oct 2014 21:52:22 +0000 (14:52 -0700)
commit3554cf91ce37c3d6e6ac3ad5f89a65a41c3852af
treefe8cdcc350c05b700e8d51f4a93bc20a05ab66d7
parentdcbcb3f64878ce4e43ba3500ba13e87e2c35397a
IB/mlx4: Avoid null pointer dereference in mlx4_ib_scan_netdevs()

commit e381835cf1b8e3b2857277dbc3b77d8c5350f70a 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: 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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/infiniband/hw/mlx4/main.c