From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
To: Thomas Fourier <fourier.thomas@gmail.com>
Cc: "Md. Haris Iqbal" <haris.iqbal@ionos.com>,
Jack Wang <jinpu.wang@ionos.com>, Jens Axboe <axboe@kernel.dk>,
Lutz Pogrell <lutz.pogrell@cloud.ionos.com>,
Md Haris Iqbal <haris.iqbal@cloud.ionos.com>,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] block: rnbd-clt: Fix leaked ID in init_dev()
Date: Tue, 16 Dec 2025 19:02:16 +0100 [thread overview]
Message-ID: <4d7c06fe-9905-4872-8e78-08c7423dd1cb@wanadoo.fr> (raw)
In-Reply-To: <20251216172203.48947-2-fourier.thomas@gmail.com>
Le 16/12/2025 à 18:22, Thomas Fourier a écrit :
> If kstrdup() fails in init_dev(), then the newly allocated ID is lost.
>
> Fixes: 64e8a6ece1a5 ("block/rnbd-clt: Dynamically alloc buffer for pathname & blk_symlink_name")
> Signed-off-by: Thomas Fourier <fourier.thomas@gmail.com>
> ---
> drivers/block/rnbd/rnbd-clt.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/block/rnbd/rnbd-clt.c b/drivers/block/rnbd/rnbd-clt.c
> index f1409e54010a..d33698eb428d 100644
> --- a/drivers/block/rnbd/rnbd-clt.c
> +++ b/drivers/block/rnbd/rnbd-clt.c
> @@ -1434,7 +1434,7 @@ static struct rnbd_clt_dev *init_dev(struct rnbd_clt_session *sess,
> dev->pathname = kstrdup(pathname, GFP_KERNEL);
> if (!dev->pathname) {
> ret = -ENOMEM;
^_______ here
> - goto out_queues;
> + goto out_ida;
> }
>
> dev->clt_device_id = ret;
> @@ -1453,6 +1453,8 @@ static struct rnbd_clt_dev *init_dev(struct rnbd_clt_session *sess,
>
> return dev;
>
> +out_ida:
> + ida_free(&index_ida, ret);
This does not work.
'ret' is being re-assigned to -ENOMEM before going there.
But there is definitively a bug to be fixed.
Maybe by assigning clt_device_id earlier and using it in the error
handling path?
CJ
> out_queues:
> kfree(dev->hw_queues);
> out_alloc:
prev parent reply other threads:[~2025-12-16 18:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-16 17:22 Thomas Fourier
2025-12-16 18:02 ` Christophe JAILLET [this message]
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=4d7c06fe-9905-4872-8e78-08c7423dd1cb@wanadoo.fr \
--to=christophe.jaillet@wanadoo.fr \
--cc=axboe@kernel.dk \
--cc=fourier.thomas@gmail.com \
--cc=haris.iqbal@cloud.ionos.com \
--cc=haris.iqbal@ionos.com \
--cc=jinpu.wang@ionos.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lutz.pogrell@cloud.ionos.com \
/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®