Skip to content

Commit 8141a2d

Browse files
Ao Zhoukuba-moo
authored andcommitted
net: rds: fix MR cleanup on copy error
__rds_rdma_map() hands sg/pages ownership to the transport after get_mr() succeeds. If copying the generated cookie back to user space fails after that point, the error path must not free those resources again before dropping the MR reference. Remove the duplicate unpin/free from the put_user() failure branch so that MR teardown is handled only through the existing final cleanup path. Fixes: 0d4597c ("net/rds: Track user mapped pages through special API") Cc: [email protected] Reported-by: Yuan Tan <[email protected]> Reported-by: Yifan Wu <[email protected]> Reported-by: Juefei Pu <[email protected]> Reported-by: Xin Liu <[email protected]> Signed-off-by: Ao Zhou <[email protected]> Signed-off-by: Ren Wei <[email protected]> Reviewed-by: Allison Henderson <[email protected]> Link: https://patch.msgid.link/79c8ef73ec8e5844d71038983940cc2943099baf.1776764247.git.draw51280@163.com Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 7256eb3 commit 8141a2d

1 file changed

Lines changed: 0 additions & 4 deletions

File tree

net/rds/rdma.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -326,10 +326,6 @@ static int __rds_rdma_map(struct rds_sock *rs, struct rds_get_mr_args *args,
326326

327327
if (args->cookie_addr &&
328328
put_user(cookie, (u64 __user *)(unsigned long)args->cookie_addr)) {
329-
if (!need_odp) {
330-
unpin_user_pages(pages, nr_pages);
331-
kfree(sg);
332-
}
333329
ret = -EFAULT;
334330
goto out;
335331
}

0 commit comments

Comments
 (0)