]> git.baikalelectronics.ru Git - kernel.git/commit
nbd: add a flush_workqueue in nbd_start_device
authorSun Ke <sunke32@huawei.com>
Wed, 22 Jan 2020 03:18:57 +0000 (11:18 +0800)
committerJens Axboe <axboe@kernel.dk>
Thu, 30 Jan 2020 04:05:53 +0000 (21:05 -0700)
commit0d2224ee216929e4955ff0de45041c41f8d68a2a
treef42e9604422c696d51a58481bdb4162a7c58988b
parentd6d865c81b91d952afff85dc20851484f10a0e2b
nbd: add a flush_workqueue in nbd_start_device

When kzalloc fail, may cause trying to destroy the
workqueue from inside the workqueue.

If num_connections is m (2 < m), and NO.1 ~ NO.n
(1 < n < m) kzalloc are successful. The NO.(n + 1)
failed. Then, nbd_start_device will return ENOMEM
to nbd_start_device_ioctl, and nbd_start_device_ioctl
will return immediately without running flush_workqueue.
However, we still have n recv threads. If nbd_release
run first, recv threads may have to drop the last
config_refs and try to destroy the workqueue from
inside the workqueue.

To fix it, add a flush_workqueue in nbd_start_device.

Fixes: 0f7abac3d749 ("nbd: fix max number of supported devs")
Signed-off-by: Sun Ke <sunke32@huawei.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/nbd.c