block: Set memalloc_noio to false on device_add_disk() error path

[ Upstream commit 5fa3d1a00c2d4ba14f1300371ad39d5456e890d7 ]

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: 25e823c8c3 ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Li Nan 2023-12-11 15:53:56 +08:00 коммит произвёл Greg Kroah-Hartman
Родитель 0296268425
Коммит 80b0b7c79f
1 изменённых файлов: 1 добавлений и 0 удалений

Просмотреть файл

@ -538,6 +538,7 @@ out_del_integrity:
out_del_block_link: out_del_block_link:
if (!sysfs_deprecated) if (!sysfs_deprecated)
sysfs_remove_link(block_depr, dev_name(ddev)); sysfs_remove_link(block_depr, dev_name(ddev));
pm_runtime_set_memalloc_noio(ddev, false);
out_device_del: out_device_del:
device_del(ddev); device_del(ddev);
out_free_ext_minor: out_free_ext_minor: