]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
ublk: use struct_size() for allocation
authorMing Lei <ming.lei@redhat.com>
Sat, 1 Nov 2025 13:31:18 +0000 (21:31 +0800)
committerJens Axboe <axboe@kernel.dk>
Mon, 3 Nov 2025 15:34:59 +0000 (08:34 -0700)
commitc28ba6b6c51d090103800eb1c7679c32f6501dbc
tree55b40d064749640a31ebb767fa39c8166889a224
parent529d4d6327880e5c60f4e0def39b3faaa7954e54
ublk: use struct_size() for allocation

Convert ublk_queue to use struct_size() for allocation.

Changes in this commit:

1. Update ublk_init_queue() to use struct_size(ubq, ios, depth)
   instead of manual size calculation (sizeof(struct ublk_queue) +
   depth * sizeof(struct ublk_io)).

This provides better type safety and makes the code more maintainable
by using standard kernel macro for flexible array handling.

Meantime annotate ublk_queue.ios by __counted_by().

Reviewed-by: Caleb Sander Mateos <csander@purestorage.com>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/ublk_drv.c