Skip to contentSkip to conversation

ublk: don't return 0 in case of any failure

PATCH Applied Ming Lei 2 participants 2 messages Apr 20, 2023

Subsystems (2)
lore
Share & tools
lore

Ming Lei

author
#0 lore raw

PATCH 1/1 ublk: don't return 0 in case of any failure

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 <[email protected]>
Fixes 2d786e66c966 ("block: ublk: switch to ioctl command encoding")
---
 drivers/block/ublk_drv.c | 1 +
 1 file changed, 1 insertion(+)
drivers/block/ublk_drv.c +1 -0
index 5a03b765a6c1..cddfb33a5c3b 100644
@@ -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 */
Signature · 1 line
2.38.1
maintainer Applied
#1 lore raw
Quoted 8 lines · Ming Lei

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,

Signature · 1 line
Jens Axboe