OSDN Git Service

net/mlx5: fix memory leak in mlx5_fw_fatal_reporter_dump
authorNavid Emamdoost <navid.emamdoost@gmail.com>
Fri, 27 Sep 2019 22:37:28 +0000 (17:37 -0500)
committerSaeed Mahameed <saeedm@mellanox.com>
Fri, 18 Oct 2019 19:11:55 +0000 (12:11 -0700)
In mlx5_fw_fatal_reporter_dump if mlx5_crdump_collect fails the
allocated memory for cr_data must be released otherwise there will be
memory leak. To fix this, this commit changes the return instruction
into goto error handling.

Fixes: 9b1f29823605 ("net/mlx5: Add support for FW fatal reporter dump")
Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
drivers/net/ethernet/mellanox/mlx5/core/health.c

index d685122..c07f315 100644 (file)
@@ -572,7 +572,7 @@ mlx5_fw_fatal_reporter_dump(struct devlink_health_reporter *reporter,
                return -ENOMEM;
        err = mlx5_crdump_collect(dev, cr_data);
        if (err)
-               return err;
+               goto free_data;
 
        if (priv_ctx) {
                struct mlx5_fw_reporter_ctx *fw_reporter_ctx = priv_ctx;