OSDN Git Service

loop: fix to a race condition due to the early registration of device
authorAnton Volkov <avolkov@ispras.ru>
Mon, 7 Aug 2017 12:37:50 +0000 (15:37 +0300)
committerJens Axboe <axboe@kernel.dk>
Tue, 15 Aug 2017 18:49:20 +0000 (12:49 -0600)
commita8c1d064d3e80aa9e3ca39e908391e433cc53f78
treee6f2c12bab61e12cf34d1b8815bb224d63a482cb
parentb3193bc0dca9bb69c8ba1ec1a318105c76eb4172
loop: fix to a race condition due to the early registration of device

The early device registration made possible a race leading to allocations
of disks with wrong minors.

This patch moves the device registration further down the loop_init
function to make the race infeasible.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Anton Volkov <avolkov@ispras.ru>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/loop.c