aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorIosif Harutyunov <iharutyunov@SonicWALL.com>2016-07-22 19:22:42 -0400
committerRichard Weinberger <richard@nod.at>2016-07-29 17:30:28 -0400
commit714fb87e8bc05ff78255afc0dca981e8c5242785 (patch)
treecca9b708d356e84bde4eef083f3b01ecd283cc5f /drivers
parent380bc8b71081a258a4cda0060803bfde47dd8c60 (diff)
ubi: Fix race condition between ubi device creation and udev
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>
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 ef3618299494..5d524a04d0a3 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -992,6 +992,9 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num,
992 goto out_detach; 992 goto out_detach;
993 } 993 }
994 994
995 /* Make device "available" before it becomes accessible via sysfs */
996 ubi_devices[ubi_num] = ubi;
997
995 err = uif_init(ubi, &ref); 998 err = uif_init(ubi, &ref);
996 if (err) 999 if (err)
997 goto out_detach; 1000 goto out_detach;
@@ -1036,7 +1039,6 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num,
1036 wake_up_process(ubi->bgt_thread); 1039 wake_up_process(ubi->bgt_thread);
1037 spin_unlock(&ubi->wl_lock); 1040 spin_unlock(&ubi->wl_lock);
1038 1041
1039 ubi_devices[ubi_num] = ubi;
1040 ubi_notify_all(ubi, UBI_VOLUME_ADDED, NULL); 1042 ubi_notify_all(ubi, UBI_VOLUME_ADDED, NULL);
1041 return ubi_num; 1043 return ubi_num;
1042 1044
@@ -1047,6 +1049,7 @@ out_uif:
1047 ubi_assert(ref); 1049 ubi_assert(ref);
1048 uif_close(ubi); 1050 uif_close(ubi);
1049out_detach: 1051out_detach:
1052 ubi_devices[ubi_num] = NULL;
1050 ubi_wl_close(ubi); 1053 ubi_wl_close(ubi);
1051 ubi_free_internal_volumes(ubi); 1054 ubi_free_internal_volumes(ubi);
1052 vfree(ubi->vtbl); 1055 vfree(ubi->vtbl);