summaryrefslogtreecommitdiff
path: root/drivers/lightnvm
diff options
context:
space:
mode:
authorMarcin Dziegielewski <marcin.dziegielewski@intel.com>2019-05-04 21:37:58 +0300
committerJens Axboe <axboe@kernel.dk>2019-05-06 19:19:18 +0300
commitf41d427cdd9ec379e35777d13622c3cd382bf0a2 (patch)
treea7b28cf575bf30ae35f4043aff62f3f11502c977 /drivers/lightnvm
parent4bbae699226ea72a91a665f489c0d85fb48885d1 (diff)
downloadlinux-f41d427cdd9ec379e35777d13622c3cd382bf0a2.tar.xz
lightnvm: prevent race condition on pblk remove
When we trigger nvm target remove during device hot unplug, there is a probability to hit a general protection fault. This is caused by use of nvm_dev thay may be freed from another (hot unplug) thread (in the nvm_unregister function). Introduce lock in nvme_ioctl_dev_remove function to prevent this situation. Signed-off-by: Marcin Dziegielewski <marcin.dziegielewski@intel.com> Reviewed-by: Javier González <javier@javigon.com> Signed-off-by: Matias Bjørling <mb@lightnvm.io> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/lightnvm')
-rw-r--r--drivers/lightnvm/core.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c
index c01f83b8fbaf..e2abe88a139c 100644
--- a/drivers/lightnvm/core.c
+++ b/drivers/lightnvm/core.c
@@ -1340,11 +1340,13 @@ static long nvm_ioctl_dev_remove(struct file *file, void __user *arg)
return -EINVAL;
}
+ down_read(&nvm_lock);
list_for_each_entry(dev, &nvm_devices, devices) {
ret = nvm_remove_tgt(dev, &remove);
if (!ret)
break;
}
+ up_read(&nvm_lock);
return ret;
}