[PATCH 4/4] ublk: factor out error handling in __ublk_ch_uring_cmd

Uday Shankar
2025-04-21T23:46:43Z

There is a tiny bit of error handling code in __ublk_ch_uring_cmd which
is repeated thrice. Factor it out of the switch statement.

Signed-off-by: Uday Shankar <ushankar@purestorage.com>
---
drivers/block/ublk_drv.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
index f5d4593d5941931efa7bc7d2106830cd2981f4bd..31ebfdf52a8986e879c136ea546755a2fbe15315 100644
--- a/drivers/block/ublk_drv.c
+++ b/drivers/block/ublk_drv.c
@@ -2095,22 +2095,18 @@ static int __ublk_ch_uring_cmd(struct io_uring_cmd *cmd,
return ublk_unregister_io_buf(cmd, ub_cmd->addr, issue_flags);
case UBLK_IO_FETCH_REQ:
ret = ublk_fetch(cmd, ubq, io, ub_cmd->addr);
- if (ret)
- goto out;
break;
case UBLK_IO_COMMIT_AND_FETCH_REQ:
ret = ublk_commit_and_fetch(ubq, io, cmd, ub_cmd);
- if (ret)
- goto out;
break;
case UBLK_IO_NEED_GET_DATA:
ret = ublk_get_data(ubq, io, cmd, ub_cmd);
- if (ret)
- goto out;
break;
default:
goto out;
}
+ if (ret)
+ goto out;
ublk_prep_cancel(cmd, issue_flags, ubq, tag);
return -EIOCBQUEUED;

--
2.34.1