diff mbox series

[v2] net/mlx5: DR, Fix uninitialized var warning

Message ID 20221110134707.43740-1-yuehaibing@huawei.com (mailing list archive)
State Awaiting Upstream
Delegated to: Netdev Maintainers
Headers show
Series [v2] net/mlx5: DR, Fix uninitialized var warning | expand

Checks

Context Check Description
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 12 of 12 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 17 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Yue Haibing Nov. 10, 2022, 1:47 p.m. UTC
Smatch warns this:

drivers/net/ethernet/mellanox/mlx5/core/steering/dr_table.c:81
 mlx5dr_table_set_miss_action() error: uninitialized symbol 'ret'.

Initializing ret with -EOPNOTSUPP and fix missing action case.

Fixes: 7838e1725394 ("net/mlx5: DR, Expose steering table functionality")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
v2: init ret to -EOPNOTSUPP
---
 drivers/net/ethernet/mellanox/mlx5/core/steering/dr_table.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Roi Dayan Nov. 10, 2022, 2:43 p.m. UTC | #1
On 10/11/2022 15:47, YueHaibing wrote:
> Smatch warns this:
> 
> drivers/net/ethernet/mellanox/mlx5/core/steering/dr_table.c:81
>  mlx5dr_table_set_miss_action() error: uninitialized symbol 'ret'.
> 
> Initializing ret with -EOPNOTSUPP and fix missing action case.
> 
> Fixes: 7838e1725394 ("net/mlx5: DR, Expose steering table functionality")
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> ---
> v2: init ret to -EOPNOTSUPP
> ---
>  drivers/net/ethernet/mellanox/mlx5/core/steering/dr_table.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_table.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_table.c
> index eb81759244d5..7cc4cb7fa392 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_table.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_table.c
> @@ -46,7 +46,7 @@ static int dr_table_set_miss_action_nic(struct mlx5dr_domain *dmn,
>  int mlx5dr_table_set_miss_action(struct mlx5dr_table *tbl,
>  				 struct mlx5dr_action *action)
>  {
> -	int ret;
> +	int ret = -EOPNOTSUPP;
>  
>  	if (action && action->action_type != DR_ACTION_TYP_FT)
>  		return -EOPNOTSUPP;
> @@ -67,6 +67,9 @@ int mlx5dr_table_set_miss_action(struct mlx5dr_table *tbl,
>  			goto out;
>  	}
>  
> +	if (ret)
> +		goto out;
> +
>  	/* Release old action */
>  	if (tbl->miss_action)
>  		refcount_dec(&tbl->miss_action->refcount);

thanks

Reviewed-by: Roi Dayan <roid@nvidia.com>
Saeed Mahameed Nov. 11, 2022, 10:19 p.m. UTC | #2
On 10 Nov 21:47, YueHaibing wrote:
>Smatch warns this:
>
>drivers/net/ethernet/mellanox/mlx5/core/steering/dr_table.c:81
> mlx5dr_table_set_miss_action() error: uninitialized symbol 'ret'.
>
>Initializing ret with -EOPNOTSUPP and fix missing action case.
>
>Fixes: 7838e1725394 ("net/mlx5: DR, Expose steering table functionality")

applied to net-mlx5, 
Thanks!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_table.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_table.c
index eb81759244d5..7cc4cb7fa392 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_table.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_table.c
@@ -46,7 +46,7 @@  static int dr_table_set_miss_action_nic(struct mlx5dr_domain *dmn,
 int mlx5dr_table_set_miss_action(struct mlx5dr_table *tbl,
 				 struct mlx5dr_action *action)
 {
-	int ret;
+	int ret = -EOPNOTSUPP;
 
 	if (action && action->action_type != DR_ACTION_TYP_FT)
 		return -EOPNOTSUPP;
@@ -67,6 +67,9 @@  int mlx5dr_table_set_miss_action(struct mlx5dr_table *tbl,
 			goto out;
 	}
 
+	if (ret)
+		goto out;
+
 	/* Release old action */
 	if (tbl->miss_action)
 		refcount_dec(&tbl->miss_action->refcount);