Skip to content

Commit 506f6d3

Browse files
calebsanderkawasaki
authored andcommitted
ublk: check cmd_op first
In preparation for skipping some of the other checks for certain IO opcodes, move the cmd_op check earlier. Signed-off-by: Caleb Sander Mateos <[email protected]> Reviewed-by: Ming Lei <[email protected]>
1 parent 3d460ec commit 506f6d3

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

drivers/block/ublk_drv.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2177,12 +2177,17 @@ static int __ublk_ch_uring_cmd(struct io_uring_cmd *cmd,
21772177
struct ublk_io *io;
21782178
u32 cmd_op = cmd->cmd_op;
21792179
unsigned tag = ub_cmd->tag;
2180-
int ret = -EINVAL;
2180+
int ret;
21812181

21822182
pr_devel("%s: received: cmd op %d queue %d tag %d result %d\n",
21832183
__func__, cmd->cmd_op, ub_cmd->q_id, tag,
21842184
ub_cmd->result);
21852185

2186+
ret = ublk_check_cmd_op(cmd_op);
2187+
if (ret)
2188+
goto out;
2189+
2190+
ret = -EINVAL;
21862191
if (ub_cmd->q_id >= ub->dev_info.nr_hw_queues)
21872192
goto out;
21882193

@@ -2215,11 +2220,6 @@ static int __ublk_ch_uring_cmd(struct io_uring_cmd *cmd,
22152220
^ (_IOC_NR(cmd_op) == UBLK_IO_NEED_GET_DATA))
22162221
goto out;
22172222

2218-
ret = ublk_check_cmd_op(cmd_op);
2219-
if (ret)
2220-
goto out;
2221-
2222-
ret = -EINVAL;
22232223
switch (_IOC_NR(cmd_op)) {
22242224
case UBLK_IO_REGISTER_IO_BUF:
22252225
return ublk_register_io_buf(cmd, ubq, tag, ub_cmd->addr, issue_flags);

0 commit comments

Comments
 (0)