]> git.baikalelectronics.ru Git - kernel.git/commit
NVMe: Do not open disks that are being deleted
authorKeith Busch <keith.busch@intel.com>
Fri, 3 Oct 2014 17:15:47 +0000 (11:15 -0600)
committerJens Axboe <axboe@fb.com>
Tue, 4 Nov 2014 20:18:32 +0000 (13:18 -0700)
commite678f7131d48efa0606e262221195564cf10c14a
treeda92850b088a1d975b2f489a67f5583f5f1d273e
parentb4622bf55bffbdcce69d0eb57d813be0509a38b3
NVMe: Do not open disks that are being deleted

It is possible the block layer will request to open a block device after
the driver deleted it. Subsequent releases will cause a double free,
or the disk's private_data is pointing to freed memory. This patch
protects the driver's freed disks from being opened and accessed: the
nvme namespaces are freed only when the device's refcount is 0, so at
that moment there were no active openers and no more should be allowed,
and it is safe to clear the disk's private_data that is about to be freed.

Signed-off-by: Keith Busch <keith.busch@intel.com>
Reported-by: Henry Chow <henry.chow@oracle.com>
Signed-off-by: Matthew Wilcox <matthew.r.wilcox@intel.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
drivers/block/nvme-core.c