block: Set memalloc_noio to false on device_add_disk() error path
authorLi Nan <linan122@huawei.com>
Mon, 11 Dec 2023 07:53:56 +0000 (15:53 +0800)
committerJens Axboe <axboe@kernel.dk>
Wed, 13 Dec 2023 15:17:02 +0000 (08:17 -0700)
On the error path of device_add_disk(), device's memalloc_noio flag was
set but not cleared. As the comment of pm_runtime_set_memalloc_noio(),
"The function should be called between device_add() and device_del()".
Clear this flag before device_del() now.

Fixes: 25e823c8c37d ("block/genhd.c: apply pm_runtime_set_memalloc_noio on block devices")
Signed-off-by: Li Nan <linan122@huawei.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20231211075356.1839282-1-linan666@huaweicloud.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/genhd.c

index c9d06f72c587e870804f1ed7a86b8971ecd397e7..13db3a7943d8f0034c899317cb3e20f53ecb7b0a 100644 (file)
@@ -542,6 +542,7 @@ out_put_holder_dir:
        kobject_put(disk->part0->bd_holder_dir);
 out_del_block_link:
        sysfs_remove_link(block_depr, dev_name(ddev));
+       pm_runtime_set_memalloc_noio(ddev, false);
 out_device_del:
        device_del(ddev);
 out_free_ext_minor: