mirror of
https://github.com/hardkernel/linux.git
synced 2026-05-31 16:26:41 +09:00
IB/mlx4: Fix shutdown crash accessing a non-existent bitmap
commit4af3ce0de0upstream. Commitcfcde11c3d("IB/mlx4: Use flow counters on IBoE ports") added code that sets elements of counters[] to -1 if no counter is allocated, but then goes ahead and passes every entry to mlx4_counter_free() on shutdown. This is a bad idea, especially if MLX4_DEV_CAP_FLAG_COUNTERS isn't set so there isn't even an underlying bitmap to free from. Tested-by: Sean Hefty <sean.hefty@intel.com> Signed-off-by: Roland Dreier <roland@purestorage.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
2c141bbe1d
commit
8b69844226
@@ -1144,7 +1144,8 @@ err_reg:
|
||||
|
||||
err_counter:
|
||||
for (; i; --i)
|
||||
mlx4_counter_free(ibdev->dev, ibdev->counters[i - 1]);
|
||||
if (ibdev->counters[i - 1] != -1)
|
||||
mlx4_counter_free(ibdev->dev, ibdev->counters[i - 1]);
|
||||
|
||||
err_map:
|
||||
iounmap(ibdev->uar_map);
|
||||
@@ -1175,7 +1176,8 @@ static void mlx4_ib_remove(struct mlx4_dev *dev, void *ibdev_ptr)
|
||||
}
|
||||
iounmap(ibdev->uar_map);
|
||||
for (p = 0; p < ibdev->num_ports; ++p)
|
||||
mlx4_counter_free(ibdev->dev, ibdev->counters[p]);
|
||||
if (ibdev->counters[p] != -1)
|
||||
mlx4_counter_free(ibdev->dev, ibdev->counters[p]);
|
||||
mlx4_foreach_port(p, dev, MLX4_PORT_TYPE_IB)
|
||||
mlx4_CLOSE_PORT(dev, p);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user