All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] net/mlx5: check for allocation failure in mlx5_ft_pool_init()
@ 2021-06-03 12:39 Dan Carpenter
  2021-06-03 13:12 ` Leon Romanovsky
  2021-06-03 19:17 ` Saeed Mahameed
  0 siblings, 2 replies; 4+ messages in thread
From: Dan Carpenter @ 2021-06-03 12:39 UTC (permalink / raw)
  To: Saeed Mahameed, Paul Blakey
  Cc: Leon Romanovsky, David S. Miller, Jakub Kicinski, netdev,
	linux-rdma, kernel-janitors

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@oracle.com>
---
 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];
-- 
2.30.2


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] net/mlx5: check for allocation failure in mlx5_ft_pool_init()
  2021-06-03 12:39 [PATCH net-next] net/mlx5: check for allocation failure in mlx5_ft_pool_init() Dan Carpenter
@ 2021-06-03 13:12 ` Leon Romanovsky
  2021-06-03 15:46   ` Dan Carpenter
  2021-06-03 19:17 ` Saeed Mahameed
  1 sibling, 1 reply; 4+ messages in thread
From: Leon Romanovsky @ 2021-06-03 13:12 UTC (permalink / raw)
  To: Dan Carpenter, Saeed Mahameed
  Cc: Paul Blakey, David S. Miller, Jakub Kicinski, netdev, linux-rdma,
	kernel-janitors

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@oracle.com>
> ---
>  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@nvidia.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] net/mlx5: check for allocation failure in mlx5_ft_pool_init()
  2021-06-03 13:12 ` Leon Romanovsky
@ 2021-06-03 15:46   ` Dan Carpenter
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2021-06-03 15:46 UTC (permalink / raw)
  To: Leon Romanovsky
  Cc: Saeed Mahameed, Paul Blakey, David S. Miller, Jakub Kicinski,
	netdev, linux-rdma, kernel-janitors

On Thu, Jun 03, 2021 at 04:12:38PM +0300, Leon Romanovsky wrote:
> 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@oracle.com>
> > ---
> >  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.

Smatch prints a static checker warning for this, but I never finished
going through the backlog of old "missing error code" warnings.  At one
point I was down to 38 warnings left but now I see that the backlog is
62 warnings so people are adding new bugs faster than I'm reviewing
them...  :P

I will take care of this tomorrow as a separate patch.  I will just
report or the other 61 warnings and get the backlog cleared out so that
I can start checking these better in the future.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] net/mlx5: check for allocation failure in mlx5_ft_pool_init()
  2021-06-03 12:39 [PATCH net-next] net/mlx5: check for allocation failure in mlx5_ft_pool_init() Dan Carpenter
  2021-06-03 13:12 ` Leon Romanovsky
@ 2021-06-03 19:17 ` Saeed Mahameed
  1 sibling, 0 replies; 4+ messages in thread
From: Saeed Mahameed @ 2021-06-03 19:17 UTC (permalink / raw)
  To: Dan Carpenter, Paul Blakey
  Cc: Leon Romanovsky, David S. Miller, Jakub Kicinski, netdev,
	linux-rdma, kernel-janitors

On Thu, 2021-06-03 at 15:39 +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@oracle.com>
> ---
>  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];

applied to net-next-mlx5,
thanks


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-06-03 19:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-03 12:39 [PATCH net-next] net/mlx5: check for allocation failure in mlx5_ft_pool_init() Dan Carpenter
2021-06-03 13:12 ` Leon Romanovsky
2021-06-03 15:46   ` Dan Carpenter
2021-06-03 19:17 ` Saeed Mahameed

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.