From: Ma Ke <make24@iscas.ac.cn>
To: haris.iqbal@ionos.com, jinpu.wang@ionos.com, jgg@ziepe.ca,
leon@kernel.org, danil.kipnis@cloud.ionos.com
Cc: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org,
akpm@linux-foundation.org, Ma Ke <make24@iscas.ac.cn>,
stable@vger.kernel.org
Subject: [PATCH] RDMA/rtrs: server: Fix error handling in get_or_create_srv
Date: Tue, 4 Nov 2025 10:19:00 +0800 [thread overview]
Message-ID: <20251104021900.11896-1-make24@iscas.ac.cn> (raw)
get_or_create_srv() fails to call put_device() after
device_initialize() when memory allocation fails. This could cause
reference count leaks during error handling, preventing proper device
cleanup and resulting in memory leaks.
Found by code review.
Cc: stable@vger.kernel.org
Fixes: 9cb837480424 ("RDMA/rtrs: server: main functionality")
Signed-off-by: Ma Ke <make24@iscas.ac.cn>
---
drivers/infiniband/ulp/rtrs/rtrs-srv.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.c b/drivers/infiniband/ulp/rtrs/rtrs-srv.c
index ef4abdea3c2d..9ecc6343455d 100644
--- a/drivers/infiniband/ulp/rtrs/rtrs-srv.c
+++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c
@@ -1450,7 +1450,7 @@ static struct rtrs_srv_sess *get_or_create_srv(struct rtrs_srv_ctx *ctx,
kfree(srv->chunks);
err_free_srv:
- kfree(srv);
+ put_device(&srv->dev);
return ERR_PTR(-ENOMEM);
}
--
2.17.1
next reply other threads:[~2025-11-04 2:19 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-04 2:19 Ma Ke [this message]
2025-11-04 6:34 ` Jinpu Wang
2025-11-04 14:55 ` Markus Elfring
2025-11-05 12:57 ` Leon Romanovsky
2025-11-05 13:46 ` Jason Gunthorpe
2025-11-05 14:51 ` Leon Romanovsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251104021900.11896-1-make24@iscas.ac.cn \
--to=make24@iscas.ac.cn \
--cc=akpm@linux-foundation.org \
--cc=danil.kipnis@cloud.ionos.com \
--cc=haris.iqbal@ionos.com \
--cc=jgg@ziepe.ca \
--cc=jinpu.wang@ionos.com \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®