net/mlx4_core: Fix error handling in mlx4_init_port_info.
authorTarick Bedeir <tarick@google.com>
Sun, 13 May 2018 23:38:45 +0000 (16:38 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 25 May 2018 14:12:55 +0000 (16:12 +0200)
commit97b7270c3dc8bee6bf43df84595fd898014e3e0c
treeeeeb9ec8880622449ae10c7bf039da88a5683a44
parent2272cdd5d5bf42e3721430ae6076656a42043c34
net/mlx4_core: Fix error handling in mlx4_init_port_info.

[ Upstream commit 57f6f99fdad9984801cde05c1db68fe39b474a10 ]

Avoid exiting the function with a lingering sysfs file (if the first
call to device_create_file() fails while the second succeeds), and avoid
calling devlink_port_unregister() twice.

In other words, either mlx4_init_port_info() succeeds and returns zero, or
it fails, returns non-zero, and requires no cleanup.

Fixes: 096335b3f983 ("mlx4_core: Allow dynamic MTU configuration for IB ports")
Signed-off-by: Tarick Bedeir <tarick@google.com>
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
Reviewed-by: Tariq Toukan <tariqt@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/ethernet/mellanox/mlx4/main.c