Skip to content

Commit 03b3d6b

Browse files
committed
io_uring/uring_cmd: ensure that device supports IOPOLL
It's possible for a file type to support uring commands, but not pollable ones. Hence before issuing one of those, we should check that it is supported and error out upfront if it isn't. Cc: [email protected] Fixes: 5756a3a ("io_uring: add iopoll infrastructure for io_uring_cmd") Link: axboe/liburing#816 Reviewed-by: Kanchan Joshi <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 01e68ce commit 03b3d6b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

io_uring/uring_cmd.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ int io_uring_cmd(struct io_kiocb *req, unsigned int issue_flags)
108108
struct file *file = req->file;
109109
int ret;
110110

111-
if (!req->file->f_op->uring_cmd)
111+
if (!file->f_op->uring_cmd)
112112
return -EOPNOTSUPP;
113113

114114
ret = security_uring_cmd(ioucmd);
@@ -120,6 +120,8 @@ int io_uring_cmd(struct io_kiocb *req, unsigned int issue_flags)
120120
if (ctx->flags & IORING_SETUP_CQE32)
121121
issue_flags |= IO_URING_F_CQE32;
122122
if (ctx->flags & IORING_SETUP_IOPOLL) {
123+
if (!file->f_op->uring_cmd_iopoll)
124+
return -EOPNOTSUPP;
123125
issue_flags |= IO_URING_F_IOPOLL;
124126
req->iopoll_completed = 0;
125127
WRITE_ONCE(ioucmd->cookie, NULL);

0 commit comments

Comments
 (0)