Skip to content

Commit 97b7270

Browse files
tarickbgregkh
authored andcommitted
net/mlx4_core: Fix error handling in mlx4_init_port_info.
[ Upstream commit 57f6f99 ] 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: 096335b ("mlx4_core: Allow dynamic MTU configuration for IB ports") Signed-off-by: Tarick Bedeir <[email protected]> Reviewed-by: Leon Romanovsky <[email protected]> Reviewed-by: Tariq Toukan <[email protected]> Signed-off-by: David S. Miller <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 2272cdd commit 97b7270

File tree

1 file changed

+3
-1
lines changed
  • drivers/net/ethernet/mellanox/mlx4

1 file changed

+3
-1
lines changed

drivers/net/ethernet/mellanox/mlx4/main.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2983,6 +2983,7 @@ static int mlx4_init_port_info(struct mlx4_dev *dev, int port)
29832983
mlx4_err(dev, "Failed to create file for port %d\n", port);
29842984
devlink_port_unregister(&info->devlink_port);
29852985
info->port = -1;
2986+
return err;
29862987
}
29872988

29882989
sprintf(info->dev_mtu_name, "mlx4_port%d_mtu", port);
@@ -3004,9 +3005,10 @@ static int mlx4_init_port_info(struct mlx4_dev *dev, int port)
30043005
&info->port_attr);
30053006
devlink_port_unregister(&info->devlink_port);
30063007
info->port = -1;
3008+
return err;
30073009
}
30083010

3009-
return err;
3011+
return 0;
30103012
}
30113013

30123014
static void mlx4_cleanup_port_info(struct mlx4_port_info *info)

0 commit comments

Comments
 (0)