2017-08-18 13:49:30

by Colin King

[permalink] [raw]
Subject: [PATCH] mlx5: ensure 0 is returned when vport is zero

From: Colin Ian King <[email protected]>

Currently, if vport is zero then then an uninialized return status
in err is returned. Since the only return status at the end of the
function esw_add_uc_addr is zero for the current set of return paths
we may as well just return 0 rather than err to fix this issue.

Detected by CoverityScan, CID#1452698 ("Uninitialized scalar variable")

Fixes: eeb66cdb6826 ("net/mlx5: Separate between E-Switch and MPFS")
Signed-off-by: Colin Ian King <[email protected]>
---
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
index 6d9fb6ac6e9b..c77f4c0c7769 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
@@ -401,7 +401,7 @@ static int esw_add_uc_addr(struct mlx5_eswitch *esw, struct vport_addr *vaddr)
esw_debug(esw->dev, "\tADDED UC MAC: vport[%d] %pM fr(%p)\n",
vport, mac, vaddr->flow_rule);

- return err;
+ return 0;
}

static int esw_del_uc_addr(struct mlx5_eswitch *esw, struct vport_addr *vaddr)
--
2.11.0


2017-08-18 16:02:16

by Leon Romanovsky

[permalink] [raw]
Subject: Re: [PATCH] mlx5: ensure 0 is returned when vport is zero

On Fri, Aug 18, 2017 at 02:49:25PM +0100, Colin King wrote:
> From: Colin Ian King <[email protected]>
>
> Currently, if vport is zero then then an uninialized return status
> in err is returned. Since the only return status at the end of the
> function esw_add_uc_addr is zero for the current set of return paths
> we may as well just return 0 rather than err to fix this issue.
>
> Detected by CoverityScan, CID#1452698 ("Uninitialized scalar variable")
>
> Fixes: eeb66cdb6826 ("net/mlx5: Separate between E-Switch and MPFS")
> Signed-off-by: Colin Ian King <[email protected]>
> ---
> drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
> index 6d9fb6ac6e9b..c77f4c0c7769 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
> @@ -401,7 +401,7 @@ static int esw_add_uc_addr(struct mlx5_eswitch *esw, struct vport_addr *vaddr)
> esw_debug(esw->dev, "\tADDED UC MAC: vport[%d] %pM fr(%p)\n",
> vport, mac, vaddr->flow_rule);
>
> - return err;
> + return 0;
> }
>

I personally prefer initialization of "err" to zero, but this solution
is fine enough too.

Thanks,
Reviewed-by: Leon Romanovsky <[email protected]>


Attachments:
(No filename) (1.35 kB)
signature.asc (833.00 B)
Download all attachments

2017-08-18 23:29:25

by David Miller

[permalink] [raw]
Subject: Re: [PATCH] mlx5: ensure 0 is returned when vport is zero

From: Colin King <[email protected]>
Date: Fri, 18 Aug 2017 14:49:25 +0100

> From: Colin Ian King <[email protected]>
>
> Currently, if vport is zero then then an uninialized return status
> in err is returned. Since the only return status at the end of the
> function esw_add_uc_addr is zero for the current set of return paths
> we may as well just return 0 rather than err to fix this issue.
>
> Detected by CoverityScan, CID#1452698 ("Uninitialized scalar variable")
>
> Fixes: eeb66cdb6826 ("net/mlx5: Separate between E-Switch and MPFS")
> Signed-off-by: Colin Ian King <[email protected]>

Applied to net-next, thanks.