summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drivers/block/rnbd/rnbd-clt-sysfs.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/drivers/block/rnbd/rnbd-clt-sysfs.c b/drivers/block/rnbd/rnbd-clt-sysfs.c
index a4508fcc7ffe..4f4474eecadb 100644
--- a/drivers/block/rnbd/rnbd-clt-sysfs.c
+++ b/drivers/block/rnbd/rnbd-clt-sysfs.c
@@ -428,12 +428,15 @@ static struct attribute *rnbd_dev_attrs[] = {
void rnbd_clt_remove_dev_symlink(struct rnbd_clt_dev *dev)
{
/*
- * The module_is_live() check is crucial and helps to avoid annoying
- * sysfs warning raised in sysfs_remove_link(), when the whole sysfs
- * path was just removed, see rnbd_close_sessions().
+ * The module unload rnbd_client_exit path is racing with unmapping of
+ * the last single device from the sysfs manually
+ * i.e. rnbd_clt_unmap_dev_store() leading to a sysfs warning because
+ * of sysfs link already was removed already.
*/
- if (strlen(dev->blk_symlink_name) && module_is_live(THIS_MODULE))
+ if (strlen(dev->blk_symlink_name) && try_module_get(THIS_MODULE)) {
sysfs_remove_link(rnbd_devs_kobj, dev->blk_symlink_name);
+ module_put(THIS_MODULE);
+ }
}
static struct kobj_type rnbd_dev_ktype = {