diff mbox series

net/mlx5: Fix dangling pointer access

Message ID 20211202221539.113434-1-amhamza.mgc@gmail.com (mailing list archive)
State Not Applicable
Headers show
Series net/mlx5: Fix dangling pointer access | expand

Commit Message

Ameer Hamza Dec. 2, 2021, 10:15 p.m. UTC
Fix for dangling pointer access reported by Coverity.

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

Signed-off-by: Ameer Hamza <amhamza.mgc@gmail.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/health.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Saeed Mahameed Dec. 2, 2021, 10:56 p.m. UTC | #1
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 <amhamza.mgc@gmail.com>
> ---
>  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/20211201063709.229103-11-saeed@kernel.org/

Thank you
diff mbox series

Patch

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;
 	}