summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorIosif Harutyunov <iharutyunov@SonicWALL.com>2016-07-22 23:22:42 +0000
committerSasha Levin <alexander.levin@verizon.com>2016-08-22 12:23:23 -0400
commitcdf25333b42fb889f086ef65d0734d0dbdc49f4e (patch)
treec6b8bbca6c332a29110446823e79d7b335f57df2 /drivers
parent6d1b8d7ad19d801a3e98f739fc6692598ece38a9 (diff)
downloadlwn-cdf25333b42fb889f086ef65d0734d0dbdc49f4e.tar.gz
lwn-cdf25333b42fb889f086ef65d0734d0dbdc49f4e.zip
ubi: Fix race condition between ubi device creation and udev
[ Upstream commit 714fb87e8bc05ff78255afc0dca981e8c5242785 ] Install the UBI device object before we arm sysfs. Otherwise udev tries to read sysfs attributes before UBI is ready and udev rules will not match. Cc: <stable@vger.kernel.org> Signed-off-by: Iosif Harutyunov <iharutyunov@sonicwall.com> [rw: massaged commit message] Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mtd/ubi/build.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index 6e30a3c280d0..c3db383a9000 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -999,6 +999,9 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num,
goto out_detach;
}
+ /* Make device "available" before it becomes accessible via sysfs */
+ ubi_devices[ubi_num] = ubi;
+
err = uif_init(ubi, &ref);
if (err)
goto out_detach;
@@ -1043,7 +1046,6 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num,
wake_up_process(ubi->bgt_thread);
spin_unlock(&ubi->wl_lock);
- ubi_devices[ubi_num] = ubi;
ubi_notify_all(ubi, UBI_VOLUME_ADDED, NULL);
return ubi_num;
@@ -1054,6 +1056,7 @@ out_uif:
ubi_assert(ref);
uif_close(ubi);
out_detach:
+ ubi_devices[ubi_num] = NULL;
ubi_wl_close(ubi);
ubi_free_internal_volumes(ubi);
vfree(ubi->vtbl);