Re: [PATCH v2] rust: block: set GenDisk block_device_operations.owner to THIS_MODULE
From: Andreas Hindborg
Date: Thu Aug 06 2026 - 05:18:07 EST
"Adarsh Das" <adarshdas950@xxxxxxxxx> 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/20260805192020.107601-1-adarshdas950@xxxxxxxxx/
>
> Signed-off-by: Adarsh Das <adarshdas950@xxxxxxxxx>
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/20260723-fix-fops-owner-v9-0-c1c3af7f7bcb@xxxxxxxxx