summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIosif Harutyunov <iharutyunov@SonicWALL.com>2016-07-22 23:22:42 +0000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-08-20 18:11:02 +0200
commitf3db4c640b32485105554e0bfd16bbde585f6fb0 (patch)
treea4850cb681c8ca5c34ad65f683f6a918a208f0ba
parent798775c3a4c8c4e75cb32ea8a3f7a4f2f9a2d186 (diff)
downloadlwn-f3db4c640b32485105554e0bfd16bbde585f6fb0.tar.gz
lwn-f3db4c640b32485105554e0bfd16bbde585f6fb0.zip
ubi: Fix race condition between ubi device creation and udev
commit 714fb87e8bc05ff78255afc0dca981e8c5242785 upstream. 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. Signed-off-by: Iosif Harutyunov <iharutyunov@sonicwall.com> [rw: massaged commit message] Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-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 45361092915a..0680516bb472 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,
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;
@@ -1036,7 +1039,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;
@@ -1047,6 +1049,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);