2021-12-02 22:15:51

by Ameer Hamza

[permalink] [raw]
Subject: [PATCH] net/mlx5: Fix dangling pointer access

Fix for dangling pointer access reported by Coverity.

Addresses-Coverity: 1494138 ("Use after free")

Signed-off-by: Ameer Hamza <[email protected]>
---
drivers/net/ethernet/mellanox/mlx5/core/health.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/health.c b/drivers/net/ethernet/mellanox/mlx5/core/health.c
index 3ca998874c50..856023321972 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/health.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/health.c
@@ -335,7 +335,7 @@ static int mlx5_health_try_recover(struct mlx5_core_dev *dev)
{
mlx5_core_warn(dev, "handling bad device here\n");
mlx5_handle_bad_state(dev);
- if (mlx5_health_wait_pci_up(dev)) {
+ if (dev->timeouts && mlx5_health_wait_pci_up(dev)) {
mlx5_core_err(dev, "health recovery flow aborted, PCI reads still not working\n");
return -EIO;
}
--
2.25.1



2021-12-02 22:56:38

by Saeed Mahameed

[permalink] [raw]
Subject: Re: [PATCH] net/mlx5: Fix dangling pointer access

On Fri, 2021-12-03 at 03:15 +0500, Ameer Hamza wrote:
> Fix for dangling pointer access reported by Coverity.
>
> Addresses-Coverity: 1494138 ("Use after free")
>
> Signed-off-by: Ameer Hamza <[email protected]>
> ---
>  drivers/net/ethernet/mellanox/mlx5/core/health.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/health.c
> b/drivers/net/ethernet/mellanox/mlx5/core/health.c
> index 3ca998874c50..856023321972 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/health.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/health.c
> @@ -335,7 +335,7 @@ static int mlx5_health_try_recover(struct
> mlx5_core_dev *dev)
>  {
>         mlx5_core_warn(dev, "handling bad device here\n");
>         mlx5_handle_bad_state(dev);
> -       if (mlx5_health_wait_pci_up(dev)) {
> +       if (dev->timeouts && mlx5_health_wait_pci_up(dev)) {


the proper fix was already submitted and accepted to net:
https://lore.kernel.org/netdev/[email protected]/

Thank you