linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ublk: don't return 0 in case of any failure
@ 2023-04-20  9:11 Ming Lei
  2023-04-20 19:04 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Ming Lei @ 2023-04-20  9:11 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block, Ming Lei, Christoph Hellwig

Commit 2d786e66c966 ("block: ublk: switch to ioctl command encoding")
starts to reset local variable of 'ret' as zero, then if any failure
happens when handling the three IO commands, 0 can be returned to ublk
server.

Fix it by returning -EINVAL in case of command handling failure.

Cc: Christoph Hellwig <hch@lst.de>
Fixes: 2d786e66c966 ("block: ublk: switch to ioctl command encoding")
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
 drivers/block/ublk_drv.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
index 5a03b765a6c1..cddfb33a5c3b 100644
--- a/drivers/block/ublk_drv.c
+++ b/drivers/block/ublk_drv.c
@@ -1315,6 +1315,7 @@ static int ublk_ch_uring_cmd(struct io_uring_cmd *cmd, unsigned int issue_flags)
 	if (ret)
 		goto out;
 
+	ret = -EINVAL;
 	switch (_IOC_NR(cmd_op)) {
 	case UBLK_IO_FETCH_REQ:
 		/* UBLK_IO_FETCH_REQ is only allowed before queue is setup */
-- 
2.38.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ublk: don't return 0 in case of any failure
  2023-04-20  9:11 [PATCH] ublk: don't return 0 in case of any failure Ming Lei
@ 2023-04-20 19:04 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2023-04-20 19:04 UTC (permalink / raw)
  To: Ming Lei; +Cc: linux-block, Christoph Hellwig


On Thu, 20 Apr 2023 17:11:04 +0800, Ming Lei wrote:
> Commit 2d786e66c966 ("block: ublk: switch to ioctl command encoding")
> starts to reset local variable of 'ret' as zero, then if any failure
> happens when handling the three IO commands, 0 can be returned to ublk
> server.
> 
> Fix it by returning -EINVAL in case of command handling failure.
> 
> [...]

Applied, thanks!

[1/1] ublk: don't return 0 in case of any failure
      (no commit info)

Best regards,
-- 
Jens Axboe




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-04-20 19:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-20  9:11 [PATCH] ublk: don't return 0 in case of any failure Ming Lei
2023-04-20 19:04 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).