On Wed, Feb 25, 2026 at 03:32:14PM +0000, John Garry wrote:
> Add support to allocate and free a multipath gendisk.
>
> NVMe has almost like-for-like equivalents here:
> - mpath_alloc_head_disk() -> nvme_mpath_alloc_disk()
> - multipath_partition_scan_work() -> nvme_partition_scan_work()
> - mpath_remove_disk() -> nvme_remove_head()
> - mpath_device_set_live() -> nvme_mpath_set_live()
>
> struct mpath_head_template is introduced as a method for drivers to
> provide custom multipath functionality.
>
> Signed-off-by: John Garry <[email protected]>
> ---
> +
> +void mpath_device_set_live(struct mpath_disk *mpath_disk,
> + struct mpath_device *mpath_device)
> +{
> + struct mpath_head *mpath_head = mpath_disk->mpath_head;
You're dereferencing mpath_disk here, before the check if it's NULL.
-Ben
> + int ret;
> +
> + if (!mpath_disk)
> + return;
> +
> + if (!test_and_set_bit(MPATH_HEAD_DISK_LIVE, &mpath_head->flags)) {
> + dev_set_drvdata(disk_to_dev(mpath_disk->disk), mpath_disk);
> + ret = device_add_disk(mpath_disk->parent, mpath_disk->disk,
> + mpath_head->mpdt->device_groups);
> + if (ret) {
> + clear_bit(MPATH_HEAD_DISK_LIVE, &mpath_head->flags);
> + return;
> + }
> + queue_work(mpath_wq, &mpath_disk->partition_scan_work);
> + }
> +}
> +EXPORT_SYMBOL_GPL(mpath_device_set_live);
> +
> struct mpath_head *mpath_alloc_head(void)
> {
> struct mpath_head *mpath_head;
> --
> 2.43.5