public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
From: Ming Lei <ming.lei@redhat.com>
To: Jens Axboe <axboe@kernel.dk>, linux-block@vger.kernel.org
Cc: Uday Shankar <ushankar@purestorage.com>,
	Caleb Sander Mateos <csander@purestorage.com>,
	Ming Lei <ming.lei@redhat.com>
Subject: [PATCH 1/2] ublk: handle ublk_set_auto_buf_reg() failure correctly in ublk_fetch()
Date: Wed, 21 May 2025 10:54:59 +0800	[thread overview]
Message-ID: <20250521025502.71041-2-ming.lei@redhat.com> (raw)
In-Reply-To: <20250521025502.71041-1-ming.lei@redhat.com>

If ublk_set_auto_buf_reg() fails, we need to unlock and return,
otherwise `ub->mutex` is leaked.

Fixes: 99c1e4eb6a3f ("ublk: register buffer to local io_uring with provided buf index via UBLK_F_AUTO_BUF_REG")
Reported-by: Caleb Sander Mateos <csander@purestorage.com>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
 drivers/block/ublk_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
index 69230f4575d4..fcf568b89370 100644
--- a/drivers/block/ublk_drv.c
+++ b/drivers/block/ublk_drv.c
@@ -2075,7 +2075,7 @@ static int ublk_fetch(struct io_uring_cmd *cmd, struct ublk_queue *ubq,
 	if (ublk_support_auto_buf_reg(ubq)) {
 		ret = ublk_set_auto_buf_reg(cmd);
 		if (ret)
-			return ret;
+			goto out;
 	}
 
 	ublk_fill_io_cmd(io, cmd, buf_addr);
-- 
2.47.0


  reply	other threads:[~2025-05-21  2:55 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-21  2:54 [PATCH 0/2] ublk: two fixes on UBLK_F_AUTO_BUF_REG Ming Lei
2025-05-21  2:54 ` Ming Lei [this message]
2025-05-21 14:53   ` [PATCH 1/2] ublk: handle ublk_set_auto_buf_reg() failure correctly in ublk_fetch() Caleb Sander Mateos
2025-05-21  2:55 ` [PATCH 2/2] ublk: run auto buf unregisgering in same io_ring_ctx with register Ming Lei
2025-05-21 15:58   ` Caleb Sander Mateos
2025-05-22  0:42     ` Ming Lei
2025-05-22  1:05       ` Caleb Sander Mateos
2025-05-22  2:37         ` Ming Lei
2025-05-21 19:19   ` Caleb Sander Mateos
2025-05-21 13:11 ` [PATCH 0/2] ublk: two fixes on UBLK_F_AUTO_BUF_REG Jens Axboe
2025-05-21 20:31   ` Jens Axboe

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=20250521025502.71041-2-ming.lei@redhat.com \
    --to=ming.lei@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=csander@purestorage.com \
    --cc=linux-block@vger.kernel.org \
    --cc=ushankar@purestorage.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