diff options
author | Iosif Harutyunov <iharutyunov@SonicWALL.com> | 2016-07-22 23:22:42 +0000 |
---|---|---|
committer | Sasha Levin <alexander.levin@verizon.com> | 2016-08-19 23:07:58 -0400 |
commit | ae32d1b98ba29408df87c0ed47877ca0f248eae7 (patch) | |
tree | 669a669d262d96411a80db4f33c61bb3f317db96 /drivers | |
parent | eb61bdda28b0fc1b7bea16919e0d34a9702d30e2 (diff) |
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.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c index b7f824d5ee88..39dba13a6f47 100644 --- a/drivers/mtd/ubi/build.c +++ b/drivers/mtd/ubi/build.c @@ -1005,6 +1005,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; @@ -1049,7 +1052,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; @@ -1060,6 +1062,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); |