All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: mellanox: mlx5: fix error return code in mlx5_fpga_device_start()
@ 2021-03-04 14:18 Jia-Ju Bai
  2021-03-04 19:58 ` Heiner Kallweit
  2021-03-07  8:50 ` Leon Romanovsky
  0 siblings, 2 replies; 4+ messages in thread
From: Jia-Ju Bai @ 2021-03-04 14:18 UTC (permalink / raw)
  To: borisp, saeedm, leon, davem, kuba
  Cc: netdev, linux-rdma, linux-kernel, Jia-Ju Bai

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(-)

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),
-- 
2.17.1


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

* Re: [PATCH] net: mellanox: mlx5: fix error return code in mlx5_fpga_device_start()
  2021-03-04 14:18 [PATCH] net: mellanox: mlx5: fix error return code in mlx5_fpga_device_start() Jia-Ju Bai
@ 2021-03-04 19:58 ` Heiner Kallweit
  2021-03-07  8:50 ` Leon Romanovsky
  1 sibling, 0 replies; 4+ messages in thread
From: Heiner Kallweit @ 2021-03-04 19:58 UTC (permalink / raw)
  To: Jia-Ju Bai, borisp, saeedm, leon, davem, kuba
  Cc: netdev, linux-rdma, linux-kernel

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),
> 


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

* Re: [PATCH] net: mellanox: mlx5: fix error return code in mlx5_fpga_device_start()
  2021-03-04 14:18 [PATCH] net: mellanox: mlx5: fix error return code in mlx5_fpga_device_start() Jia-Ju Bai
  2021-03-04 19:58 ` Heiner Kallweit
@ 2021-03-07  8:50 ` Leon Romanovsky
  2021-03-11 22:51   ` Saeed Mahameed
  1 sibling, 1 reply; 4+ messages in thread
From: Leon Romanovsky @ 2021-03-07  8:50 UTC (permalink / raw)
  To: Jia-Ju Bai; +Cc: borisp, saeedm, davem, kuba, netdev, linux-rdma, linux-kernel

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

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

* Re: [PATCH] net: mellanox: mlx5: fix error return code in mlx5_fpga_device_start()
  2021-03-07  8:50 ` Leon Romanovsky
@ 2021-03-11 22:51   ` Saeed Mahameed
  0 siblings, 0 replies; 4+ messages in thread
From: Saeed Mahameed @ 2021-03-11 22:51 UTC (permalink / raw)
  To: Leon Romanovsky, Jia-Ju Bai
  Cc: borisp, davem, kuba, netdev, linux-rdma, linux-kernel

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, 




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

end of thread, other threads:[~2021-03-11 22:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-04 14:18 [PATCH] net: mellanox: mlx5: fix error return code in mlx5_fpga_device_start() Jia-Ju Bai
2021-03-04 19:58 ` Heiner Kallweit
2021-03-07  8:50 ` Leon Romanovsky
2021-03-11 22:51   ` 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.