mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-24 13:40:53 +07:00
RDMA/mlx5: Fix prefetch memory leak if get_prefetchable_mr fails
destroy_prefetch_work() must always be called if the work is not going
to be queued. The num_sge also should have been set to i, not i-1
which avoids the condition where it shouldn't have been called in the
first place.
Cc: stable@vger.kernel.org
Fixes: fb985e278a
("RDMA/mlx5: Use SRCU properly in ODP prefetch")
Link: https://lore.kernel.org/r/20200727095712.495652-1-leon@kernel.org
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
This commit is contained in:
parent
31142a4ba6
commit
5351a56b1a
@ -1797,9 +1797,7 @@ static bool init_prefetch_work(struct ib_pd *pd,
|
|||||||
work->frags[i].mr =
|
work->frags[i].mr =
|
||||||
get_prefetchable_mr(pd, advice, sg_list[i].lkey);
|
get_prefetchable_mr(pd, advice, sg_list[i].lkey);
|
||||||
if (!work->frags[i].mr) {
|
if (!work->frags[i].mr) {
|
||||||
work->num_sge = i - 1;
|
work->num_sge = i;
|
||||||
if (i)
|
|
||||||
destroy_prefetch_work(work);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1865,6 +1863,7 @@ int mlx5_ib_advise_mr_prefetch(struct ib_pd *pd,
|
|||||||
srcu_key = srcu_read_lock(&dev->odp_srcu);
|
srcu_key = srcu_read_lock(&dev->odp_srcu);
|
||||||
if (!init_prefetch_work(pd, advice, pf_flags, work, sg_list, num_sge)) {
|
if (!init_prefetch_work(pd, advice, pf_flags, work, sg_list, num_sge)) {
|
||||||
srcu_read_unlock(&dev->odp_srcu, srcu_key);
|
srcu_read_unlock(&dev->odp_srcu, srcu_key);
|
||||||
|
destroy_prefetch_work(work);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
queue_work(system_unbound_wq, &work->work);
|
queue_work(system_unbound_wq, &work->work);
|
||||||
|
Loading…
Reference in New Issue
Block a user