diff mbox series

net: mellanox: mlx5: fix error return code in mlx5_fpga_device_start()

Message ID 20210304141814.8508-1-baijiaju1990@gmail.com (mailing list archive)
State Awaiting Upstream
Delegated to: Netdev Maintainers
Headers show
Series net: mellanox: mlx5: fix error return code in mlx5_fpga_device_start() | 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 8 of 8 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, 11 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

Jia-Ju Bai March 4, 2021, 2:18 p.m. UTC
When mlx5_is_fpga_lookaside() returns a non-zero value, no error 
return code is assigned.
To fix this bug, err is assigned with -EINVAL as error return code.

Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/fpga/core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Heiner Kallweit March 4, 2021, 7:58 p.m. UTC | #1
On 04.03.2021 15:18, Jia-Ju Bai wrote:
> When mlx5_is_fpga_lookaside() returns a non-zero value, no error 
> return code is assigned.
> To fix this bug, err is assigned with -EINVAL as error return code.
> 
To me it looks like the current behavior is intentional.
Did you verify that it's actually an error condition if the
function returns true? Please don't blindly trust such code checkers.

> Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
> Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
> ---
>  drivers/net/ethernet/mellanox/mlx5/core/fpga/core.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fpga/core.c b/drivers/net/ethernet/mellanox/mlx5/core/fpga/core.c
> index 2ce4241459ce..c9e6da97126f 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/fpga/core.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/fpga/core.c
> @@ -198,8 +198,10 @@ int mlx5_fpga_device_start(struct mlx5_core_dev *mdev)
>  	mlx5_fpga_info(fdev, "FPGA card %s:%u\n", mlx5_fpga_name(fpga_id), fpga_id);
>  
>  	/* No QPs if FPGA does not participate in net processing */
> -	if (mlx5_is_fpga_lookaside(fpga_id))
> +	if (mlx5_is_fpga_lookaside(fpga_id)) {
> +		err = -EINVAL;
>  		goto out;
> +	}
>  
>  	mlx5_fpga_info(fdev, "%s(%d): image, version %u; SBU %06x:%04x version %d\n",
>  		       mlx5_fpga_image_name(fdev->last_oper_image),
>
Leon Romanovsky March 7, 2021, 8:50 a.m. UTC | #2
On Thu, Mar 04, 2021 at 06:18:14AM -0800, Jia-Ju Bai wrote:
> When mlx5_is_fpga_lookaside() returns a non-zero value, no error
> return code is assigned.
> To fix this bug, err is assigned with -EINVAL as error return code.
>
> Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
> Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
> ---
>  drivers/net/ethernet/mellanox/mlx5/core/fpga/core.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

Like Heiner said, the current code has correct behavior.
The mlx5_fpga_device_load_check() has same mlx5_is_fpga_lookaside()
check and it is not an error if it returns true.

NAK: Leon Romanovsky <leonro@nvidia.com>

Thanks
Saeed Mahameed March 11, 2021, 10:51 p.m. UTC | #3
On Sun, 2021-03-07 at 10:50 +0200, Leon Romanovsky wrote:
> On Thu, Mar 04, 2021 at 06:18:14AM -0800, Jia-Ju Bai wrote:
> > When mlx5_is_fpga_lookaside() returns a non-zero value, no error
> > return code is assigned.
> > To fix this bug, err is assigned with -EINVAL as error return code.
> > 
> > Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
> > Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
> > ---
> >  drivers/net/ethernet/mellanox/mlx5/core/fpga/core.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> Like Heiner said, the current code has correct behavior.
> The mlx5_fpga_device_load_check() has same mlx5_is_fpga_lookaside()
> check and it is not an error if it returns true.
> 
> NAK: Leon Romanovsky <leonro@nvidia.com>
> 
> Thanks

Agreed, apparently this robot is looking for "goto {out|*err*}"
statements and treats all of them as errors, this is very unreliable,
diff mbox series

Patch

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fpga/core.c b/drivers/net/ethernet/mellanox/mlx5/core/fpga/core.c
index 2ce4241459ce..c9e6da97126f 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fpga/core.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fpga/core.c
@@ -198,8 +198,10 @@  int mlx5_fpga_device_start(struct mlx5_core_dev *mdev)
 	mlx5_fpga_info(fdev, "FPGA card %s:%u\n", mlx5_fpga_name(fpga_id), fpga_id);
 
 	/* No QPs if FPGA does not participate in net processing */
-	if (mlx5_is_fpga_lookaside(fpga_id))
+	if (mlx5_is_fpga_lookaside(fpga_id)) {
+		err = -EINVAL;
 		goto out;
+	}
 
 	mlx5_fpga_info(fdev, "%s(%d): image, version %u; SBU %06x:%04x version %d\n",
 		       mlx5_fpga_image_name(fdev->last_oper_image),