ublk: don't cast registered buffer index to int
Subsystems (2)
PATCH 1/1 ublk: don't cast registered buffer index to int
io_buffer_register_bvec() takes index as an unsigned int argument, but ublk_register_io_buf() casts ub_cmd->addr (a u64) to int. Remove the misleading cast and instead pass index as an unsigned value to ublk_register_io_buf() and ublk_unregister_io_buf().
--- drivers/block/ublk_drv.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/block/ublk_drv.c +6 -8
@@ -1760,16 +1760,15 @@ static void ublk_io_release(void *priv)ublk_put_req_ref (ubq, rq); }static int ublk_register_io_buf (struct io_uring_cmd *cmd,struct ublk_queue *ubq,unsigned int tag, -const struct ublksrv_io_cmd *ub_cmd, -unsigned int issue_flags) +unsigned int index,unsigned int issue_flags) {struct ublk_device *ub = cmd->file->private_data; -int index = (int )ub_cmd->addr, ret;struct request *req; +int ret; req =__ublk_check_and_get_req (ub, ubq, tag,0 );if (!req)return -EINVAL ;
@@ -1782,14 +1781,13 @@ static int ublk_register_io_buf(struct io_uring_cmd *cmd,return 0 ; }static int ublk_unregister_io_buf (struct io_uring_cmd *cmd, -const struct ublksrv_io_cmd *ub_cmd, -unsigned int issue_flags) +unsigned int index,unsigned int issue_flags) { -return io_buffer_unregister_bvec (cmd, ub_cmd->addr, issue_flags); +return io_buffer_unregister_bvec (cmd, index, issue_flags); }static int __ublk_ch_uring_cmd (struct io_uring_cmd *cmd,unsigned int issue_flags,const struct ublksrv_io_cmd *ub_cmd)
@@ -1840,13 +1838,13 @@ static int __ublk_ch_uring_cmd(struct io_uring_cmd *cmd, goto out; ret = -EINVAL ;switch (_IOC_NR (cmd_op)) {case UBLK_IO_REGISTER_IO_BUF : -return ublk_register_io_buf (cmd, ubq, tag, ub_cmd, issue_flags); +return ublk_register_io_buf (cmd, ubq, tag, ub_cmd->addr, issue_flags);case UBLK_IO_UNREGISTER_IO_BUF : -return ublk_unregister_io_buf (cmd, ub_cmd, issue_flags); +return ublk_unregister_io_buf (cmd, ub_cmd->addr, issue_flags);case UBLK_IO_FETCH_REQ :/* UBLK_IO_FETCH_REQ is only allowed before queue is setup */ if (ublk_queue_ready (ubq)) { ret = -EBUSY ; goto out;
Signature · 1 line
2.45.2
Quoted 6 lines · Caleb Sander Mateos
io_buffer_register_bvec()takes index as an unsigned int argument, butublk_register_io_buf()castsub_cmd->addr(a u64) to int. Remove the misleading cast and instead pass index as an unsigned value toublk_register_io_buf()andublk_unregister_io_buf().Signed-off-by Caleb Sander Mateos <[email protected]>
Thanks,
Ming
Quoted 6 lines · Caleb Sander Mateos
io_buffer_register_bvec()takes index as an unsigned int argument, butublk_register_io_buf()castsub_cmd->addr(a u64) to int. Remove the misleading cast and instead pass index as an unsigned value toublk_register_io_buf()andublk_unregister_io_buf().
Applied, thanks!
[1/1] ublk: don't cast registered buffer index to int
commit: 9e12d09cfdaf89db894abdad392bb8dcd6c0f464
Best regards,
Signature · 1 line
Jens Axboe