]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: rds: fix MR cleanup on copy error
authorAo Zhou <draw51280@163.com>
Wed, 22 Apr 2026 14:52:07 +0000 (22:52 +0800)
committerJakub Kicinski <kuba@kernel.org>
Thu, 23 Apr 2026 19:18:08 +0000 (12:18 -0700)
__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: 0d4597c8c5ab ("net/rds: Track user mapped pages through special API")
Cc: stable@kernel.org
Reported-by: Yuan Tan <yuantan098@gmail.com>
Reported-by: Yifan Wu <yifanwucs@gmail.com>
Reported-by: Juefei Pu <tomapufckgml@gmail.com>
Reported-by: Xin Liu <bird@lzu.edu.cn>
Signed-off-by: Ao Zhou <draw51280@163.com>
Signed-off-by: Ren Wei <n05ec@lzu.edu.cn>
Reviewed-by: Allison Henderson <achender@kernel.org>
Link: https://patch.msgid.link/79c8ef73ec8e5844d71038983940cc2943099baf.1776764247.git.draw51280@163.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/rds/rdma.c

index aa6465dc742c2db14558b4e678c71c7c51867ef7..61fb6e45281bf1bfdac14ef41f4652458d41dabe 100644 (file)
@@ -326,10 +326,6 @@ static int __rds_rdma_map(struct rds_sock *rs, struct rds_get_mr_args *args,
 
        if (args->cookie_addr &&
            put_user(cookie, (u64 __user *)(unsigned long)args->cookie_addr)) {
-               if (!need_odp) {
-                       unpin_user_pages(pages, nr_pages);
-                       kfree(sg);
-               }
                ret = -EFAULT;
                goto out;
        }