Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ublk: specify io_cmd_buf pointer type

io_cmd_buf points to an array of ublksrv_io_desc structs but its type is
char *. Indexing the array requires an explicit multiplication and cast.
The compiler also can't check the pointer types.

Change io_cmd_buf's type to struct ublksrv_io_desc * so it can be
indexed directly and the compiler can type-check the code.

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Acked-by: Shuah Khan <skhan@linuxfoundation.org>
Link: https://lore.kernel.org/r/20250328194230.2726862-2-csander@purestorage.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Caleb Sander Mateos and committed by
Jens Axboe
9a45714f ea910678

+4 -4
+4 -4
drivers/block/ublk_drv.c
··· 158 158 159 159 unsigned long flags; 160 160 struct task_struct *ubq_daemon; 161 - char *io_cmd_buf; 161 + struct ublksrv_io_desc *io_cmd_buf; 162 162 163 163 bool force_abort; 164 164 bool timeout; ··· 706 706 static inline struct ublksrv_io_desc *ublk_get_iod(struct ublk_queue *ubq, 707 707 int tag) 708 708 { 709 - return (struct ublksrv_io_desc *) 710 - &(ubq->io_cmd_buf[tag * sizeof(struct ublksrv_io_desc)]); 709 + return &ubq->io_cmd_buf[tag]; 711 710 } 712 711 713 - static inline char *ublk_queue_cmd_buf(struct ublk_device *ub, int q_id) 712 + static inline struct ublksrv_io_desc * 713 + ublk_queue_cmd_buf(struct ublk_device *ub, int q_id) 714 714 { 715 715 return ublk_get_queue(ub, q_id)->io_cmd_buf; 716 716 }