From: Kamal Heib Date: Thu, 17 Aug 2017 12:52:31 +0000 (+0300) Subject: IB/mlx5: Fix memory leak in clean_mr error path X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=5942d8ae411775b76e5e1ab0cce57b0666516f2d;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git IB/mlx5: Fix memory leak in clean_mr error path In clean_mr error path the 'mr' should be freed. Fixes: e126ba97dba9 ('mlx5: Add driver for Mellanox Connect-IB adapters') Signed-off-by: Kamal Heib Signed-off-by: Doug Ledford --- diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/mr.c index aa6f71570b77..8cf53eb13148 100644 --- a/drivers/infiniband/hw/mlx5/mr.c +++ b/drivers/infiniband/hw/mlx5/mr.c @@ -1490,19 +1490,19 @@ static int clean_mr(struct mlx5_ib_mr *mr) mlx5_free_priv_descs(mr); if (!allocated_from_cache) { + u32 key = mr->mmkey.key; + err = destroy_mkey(dev, mr); + kfree(mr); if (err) { mlx5_ib_warn(dev, "failed to destroy mkey 0x%x (%d)\n", - mr->mmkey.key, err); + key, err); return err; } } else { mlx5_mr_cache_free(dev, mr); } - if (!allocated_from_cache) - kfree(mr); - return 0; }