IB/mlx5: Fix memory leak in clean_mr error path

In clean_mr error path the 'mr' should be freed.

Fixes: e126ba97db ('mlx5: Add driver for Mellanox Connect-IB adapters')
Signed-off-by: Kamal Heib <kamalh@mellanox.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
This commit is contained in:
Kamal Heib 2017-08-17 15:52:31 +03:00 committed by Doug Ledford
parent ff740aefec
commit 5942d8ae41
1 changed files with 4 additions and 4 deletions

View File

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