On Wed, Mar 10, 2021 at 01:11:15PM +0000, Luis Chamberlain wrote: > I can try to modify it to include second patch first, as that is > required. There are two separate bugs here. I tried this, applying the syfs required changes first and then applying your idea as a secondary patch ends up like this: diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index 4b57c84ba9d4..bb45c1e0f3e0 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -1702,6 +1702,7 @@ static void zram_reset_device(struct zram *zram) set_capacity_and_notify(zram->disk, 0); part_stat_set_all(zram->disk->part0, 0); + module_put(THIS_MODULE); up_write(&zram->init_lock); /* I/O operation under all of CPU are done so let's free */ @@ -1747,6 +1748,7 @@ static ssize_t disksize_store(struct device *dev, goto out_free_meta; } + BUG_ON(!try_module_get(THIS_MODULE)); zram->comp = comp; zram->disksize = disksize; set_capacity_and_notify(zram->disk, zram->disksize >> SECTOR_SHIFT); The BUG_ON() is doable as we *know* we already have a reference to the module due to the beginning of the other try_module_get() which would be placed on the first patch at the top of disksize_store(). This however doesn't fix the issue. We end up in a situation where we cannot unload the zram driver. Luis