diff mbox series

net/mlx5: use kvfree() for memory allocated with kvzalloc()

Message ID 20210303024019.2245-1-angkery@163.com (mailing list archive)
State Awaiting Upstream
Delegated to: Netdev Maintainers
Headers show
Series net/mlx5: use kvfree() for memory allocated with kvzalloc() | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Guessed tree name to be net-next
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cc_maintainers success CCed 11 of 11 maintainers
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 34 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link
netdev/stable success Stable not CCed

Commit Message

Junlin Yang March 3, 2021, 2:40 a.m. UTC
From: Junlin Yang <yangjunlin@yulong.com>

It is allocated with kvzalloc(), the corresponding release function
should not be kfree(), use kvfree() instead.

Generated by: scripts/coccinelle/api/kfree_mismatch.cocci

Signed-off-by: Junlin Yang <yangjunlin@yulong.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/esw/indir_table.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Roi Dayan March 3, 2021, 7:54 a.m. UTC | #1
On 2021-03-03 4:40 AM, angkery wrote:
> From: Junlin Yang <yangjunlin@yulong.com>
> 
> It is allocated with kvzalloc(), the corresponding release function
> should not be kfree(), use kvfree() instead.
> 
> Generated by: scripts/coccinelle/api/kfree_mismatch.cocci
> 
> Signed-off-by: Junlin Yang <yangjunlin@yulong.com>
> ---
>   drivers/net/ethernet/mellanox/mlx5/core/esw/indir_table.c | 10 +++++-----
>   1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/esw/indir_table.c b/drivers/net/ethernet/mellanox/mlx5/core/esw/indir_table.c
> index 6f6772b..3da7bec 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/esw/indir_table.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/esw/indir_table.c
> @@ -248,7 +248,7 @@ static int mlx5_esw_indir_table_rule_get(struct mlx5_eswitch *esw,
>   err_ethertype:
>   	kfree(rule);
>   out:
> -	kfree(rule_spec);
> +	kvfree(rule_spec);
>   	return err;
>   }
>   
> @@ -328,7 +328,7 @@ static int mlx5_create_indir_recirc_group(struct mlx5_eswitch *esw,
>   	e->recirc_cnt = 0;
>   
>   out:
> -	kfree(in);
> +	kvfree(in);
>   	return err;
>   }
>   
> @@ -347,7 +347,7 @@ static int mlx5_create_indir_fwd_group(struct mlx5_eswitch *esw,
>   
>   	spec = kvzalloc(sizeof(*spec), GFP_KERNEL);
>   	if (!spec) {
> -		kfree(in);
> +		kvfree(in);
>   		return -ENOMEM;
>   	}
>   
> @@ -371,8 +371,8 @@ static int mlx5_create_indir_fwd_group(struct mlx5_eswitch *esw,
>   	}
>   
>   err_out:
> -	kfree(spec);
> -	kfree(in);
> +	kvfree(spec);
> +	kvfree(in);
>   	return err;
>   }
>   
> 

thanks!

Reviewed-by: Roi Dayan <roid@nvidia.com>
Saeed Mahameed March 11, 2021, 11:26 p.m. UTC | #2
On Wed, 2021-03-03 at 09:54 +0200, Roi Dayan wrote:
> 
> 
> On 2021-03-03 4:40 AM, angkery wrote:
> > From: Junlin Yang <yangjunlin@yulong.com>
> > 
> > It is allocated with kvzalloc(), the corresponding release function
> > should not be kfree(), use kvfree() instead.
> > 
> > Generated by: scripts/coccinelle/api/kfree_mismatch.cocci
> > 
> > Signed-off-by: Junlin Yang <yangjunlin@yulong.com>
> > ---
> >   drivers/net/ethernet/mellanox/mlx5/core/esw/indir_table.c | 10
> > +++++-----
> >   1 file changed, 5 insertions(+), 5 deletions(-)
> > 
> > diff --git
> > a/drivers/net/ethernet/mellanox/mlx5/core/esw/indir_table.c
> > b/drivers/net/ethernet/mellanox/mlx5/core/esw/indir_table.c
> > index 6f6772b..3da7bec 100644
> > --- a/drivers/net/ethernet/mellanox/mlx5/core/esw/indir_table.c
> > +++ b/drivers/net/ethernet/mellanox/mlx5/core/esw/indir_table.c
> > @@ -248,7 +248,7 @@ static int mlx5_esw_indir_table_rule_get(struct
> > mlx5_eswitch *esw,
> >   err_ethertype:
> >         kfree(rule);
> >   out:
> > -       kfree(rule_spec);
> > +       kvfree(rule_spec);
> >         return err;
> >   }
> >   
> > @@ -328,7 +328,7 @@ static int
> > mlx5_create_indir_recirc_group(struct mlx5_eswitch *esw,
> >         e->recirc_cnt = 0;
> >   
> >   out:
> > -       kfree(in);
> > +       kvfree(in);
> >         return err;
> >   }
> >   
> > @@ -347,7 +347,7 @@ static int mlx5_create_indir_fwd_group(struct
> > mlx5_eswitch *esw,
> >   
> >         spec = kvzalloc(sizeof(*spec), GFP_KERNEL);
> >         if (!spec) {
> > -               kfree(in);
> > +               kvfree(in);
> >                 return -ENOMEM;
> >         }
> >   
> > @@ -371,8 +371,8 @@ static int mlx5_create_indir_fwd_group(struct
> > mlx5_eswitch *esw,
> >         }
> >   
> >   err_out:
> > -       kfree(spec);
> > -       kfree(in);
> > +       kvfree(spec);
> > +       kvfree(in);
> >         return err;
> >   }
> >   
> > 
> 
> thanks!
> 
> Reviewed-by: Roi Dayan <roid@nvidia.com>
> 

applied to net-next-mlx5
diff mbox series

Patch

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/esw/indir_table.c b/drivers/net/ethernet/mellanox/mlx5/core/esw/indir_table.c
index 6f6772b..3da7bec 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/esw/indir_table.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/esw/indir_table.c
@@ -248,7 +248,7 @@  static int mlx5_esw_indir_table_rule_get(struct mlx5_eswitch *esw,
 err_ethertype:
 	kfree(rule);
 out:
-	kfree(rule_spec);
+	kvfree(rule_spec);
 	return err;
 }
 
@@ -328,7 +328,7 @@  static int mlx5_create_indir_recirc_group(struct mlx5_eswitch *esw,
 	e->recirc_cnt = 0;
 
 out:
-	kfree(in);
+	kvfree(in);
 	return err;
 }
 
@@ -347,7 +347,7 @@  static int mlx5_create_indir_fwd_group(struct mlx5_eswitch *esw,
 
 	spec = kvzalloc(sizeof(*spec), GFP_KERNEL);
 	if (!spec) {
-		kfree(in);
+		kvfree(in);
 		return -ENOMEM;
 	}
 
@@ -371,8 +371,8 @@  static int mlx5_create_indir_fwd_group(struct mlx5_eswitch *esw,
 	}
 
 err_out:
-	kfree(spec);
-	kfree(in);
+	kvfree(spec);
+	kvfree(in);
 	return err;
 }