Re: [PATCH net-next] net/mlx5: check for allocation failure in mlx5_ft_pool_init()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jun 03, 2021 at 03:39:24PM +0300, Dan Carpenter wrote:
> Add a check for if the kzalloc() fails.
> 
> Fixes: 4a98544d1827 ("net/mlx5: Move chains ft pool to be used by all firmware steering")
> Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
> ---
>  drivers/net/ethernet/mellanox/mlx5/core/fs_ft_pool.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_ft_pool.c b/drivers/net/ethernet/mellanox/mlx5/core/fs_ft_pool.c
> index 526fbb669142..c14590acc772 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/fs_ft_pool.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_ft_pool.c
> @@ -27,6 +27,8 @@ int mlx5_ft_pool_init(struct mlx5_core_dev *dev)
>  	int i;
>  
>  	ft_pool = kzalloc(sizeof(*ft_pool), GFP_KERNEL);
> +	if (!ft_pool)
> +		return -ENOMEM;
>  
>  	for (i = ARRAY_SIZE(FT_POOLS) - 1; i >= 0; i--)
>  		ft_pool->ft_left[i] = FT_SIZE / FT_POOLS[i];


Dan thanks for your patch.

When reviewed your patch, I spotted another error in the patch from the Fixes line.

  2955         err = mlx5_ft_pool_init(dev);
  2956         if (err)
  2957                 return err;
  2958
  2959         steering = kzalloc(sizeof(*steering), GFP_KERNEL);
  2960         if (!steering)
  2961                 goto err;
                       ^^^^^^^^ it will return success, while should return ENOMEM.

Thanks,
Acked-by: Leon Romanovsky <leonro@xxxxxxxxxx>



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux