]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net/mlx5: Fix memory leak in mlx5_events_init
authorMoshe Shemesh <moshe@mellanox.com>
Wed, 29 Apr 2020 20:56:58 +0000 (23:56 +0300)
committerSaeed Mahameed <saeedm@mellanox.com>
Sat, 23 May 2020 00:28:46 +0000 (17:28 -0700)
Fix memory leak in mlx5_events_init(), in case
create_single_thread_workqueue() fails, events
struct should be freed.

Fixes: ae7bed299fc4 ("net/mlx5: Handle event of power detection in the PCIE slot")
Signed-off-by: Moshe Shemesh <moshe@mellanox.com>
Reviewed-by: Tariq Toukan <tariqt@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
drivers/net/ethernet/mellanox/mlx5/core/events.c

index 8bcf3426b9c6ad454792a75d748d87e02e0ec698..3ce17c3d7a0014082b74a5ac00428935a76f48b9 100644 (file)
@@ -346,8 +346,10 @@ int mlx5_events_init(struct mlx5_core_dev *dev)
        events->dev = dev;
        dev->priv.events = events;
        events->wq = create_singlethread_workqueue("mlx5_events");
-       if (!events->wq)
+       if (!events->wq) {
+               kfree(events);
                return -ENOMEM;
+       }
        INIT_WORK(&events->pcie_core_work, mlx5_pcie_event);
 
        return 0;