Re: [PATCH v2] rust: block: set GenDisk block_device_operations.owner to THIS_MODULE

Andreas Hindborg <[email protected]> Thu, 06 Aug 2026 11:08:05 +0200
Newsgroups org.kernel.vger.linux-block,org.kernel.vger.linux-kernel,org.kernel.vger.rust-for-linux
Message-ID <[email protected]>
"Adarsh Das" <[email protected]> writes:

> GenDiskBuilder left block_device_operations.owner NULL. Pass the driver's
> ThisModule into GenDiskBuilder::build(), heap-allocate the operations
> table, and keep it alive until the gendisk is released via free_disk.
> Update rnull as the in-tree caller.
>
> v2:
> - Free fops in free_disk instead of GenDisk::drop to fix use-after-free
>   when the device stays open after removal. (Sashiko)
> - Install the cleanup guard before fops allocation to avoid leaking gendisk
>   on -ENOMEM. (Sashiko)
> - Link to v1: https://lore.kernel.org/all/[email protected]/
>
> Signed-off-by: Adarsh Das <[email protected]>

The reason `owner` is not set is that we want to keep the vtable const.
But with Alvins recent series [1], we should be able to set owner in
const context.

Can you rebase on his series and see if you can make it work in const context?


Best regards,
Andreas Hindborg


[1] https://lore.kernel.org/r/[email protected]