[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190504183811.18725-14-mb@lightnvm.io>
Date: Sat, 4 May 2019 20:37:58 +0200
From: Matias Bjørling <mb@...htnvm.io>
To: axboe@...com
Cc: linux-block@...r.kernel.org, linux-kernel@...r.kernel.org,
Marcin Dziegielewski <marcin.dziegielewski@...el.com>,
Matias Bjørling <mb@...htnvm.io>
Subject: [GIT PULL 13/26] lightnvm: prevent race condition on pblk remove
From: Marcin Dziegielewski <marcin.dziegielewski@...el.com>
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@...el.com>
Reviewed-by: Javier González <javier@...igon.com>
Signed-off-by: Matias Bjørling <mb@...htnvm.io>
---
drivers/lightnvm/core.c | 2 ++
1 file changed, 2 insertions(+)
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;
}
--
2.19.1
Powered by blists - more mailing lists