Skip to contentSkip to conversation

net/mlx5: fix memory leak in mlx5_fw_fatal_reporter_dump

PATCH Applied Navid Emamdoost 3 participants 3 messages Sep 27, 2019 – Oct 15, 2019

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/mlx5: fix memory leak in mlx5_fw_fatal_reporter_dump

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")
---
 drivers/net/ethernet/mellanox/mlx5/core/health.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/health.c +1 -1
index d685122d9ff7..c07f3154437c 100644
@@ -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;
Signature · 1 line
2.17.1
#1 lore raw
Quoted 11 lines · Navid Emamdoost

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")
---
 drivers/net/ethernet/mellanox/mlx5/core/health.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

General note, if you don't write "To:" in your emails, most probably your emails will be missed by relevant people.

I assume that Saeed will pick this patch and fix extra line between Fixes and SOB.

Thanks, for fixing it.

#2 lore raw
In reply to Navid Emamdoost
Quoted 10 lines · Navid Emamdoost

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

Applied to net-next-mlx5, will be sent to net-next shortly, i will fix the extra empty line as Leon pointed out.

Thanks,
Saeed.

Quoted 20 lines
---
 drivers/net/ethernet/mellanox/mlx5/core/health.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/health.c +1 -1
index d685122d9ff7..c07f3154437c 100644
@@ -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;