ubi: Fix race condition between ubi volume creation and udev
commit a51a0c8d213594bc094cb8e54aad0cb6d7f7b9a6 upstream. Similar to commit 714fb87e8bc0 ("ubi: Fix race condition between ubi device creation and udev"), we should make the volume active before registering it. Signed-off-by: Clay McClure <clay@daemons.net> Cc: <stable@vger.kernel.org> Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
0683564edc
commit
35482f62d4
1 changed files with 10 additions and 5 deletions
|
@ -265,6 +265,12 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req)
|
||||||
vol->last_eb_bytes = vol->usable_leb_size;
|
vol->last_eb_bytes = vol->usable_leb_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Make volume "available" before it becomes accessible via sysfs */
|
||||||
|
spin_lock(&ubi->volumes_lock);
|
||||||
|
ubi->volumes[vol_id] = vol;
|
||||||
|
ubi->vol_count += 1;
|
||||||
|
spin_unlock(&ubi->volumes_lock);
|
||||||
|
|
||||||
/* Register character device for the volume */
|
/* Register character device for the volume */
|
||||||
cdev_init(&vol->cdev, &ubi_vol_cdev_operations);
|
cdev_init(&vol->cdev, &ubi_vol_cdev_operations);
|
||||||
vol->cdev.owner = THIS_MODULE;
|
vol->cdev.owner = THIS_MODULE;
|
||||||
|
@ -304,11 +310,6 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req)
|
||||||
if (err)
|
if (err)
|
||||||
goto out_sysfs;
|
goto out_sysfs;
|
||||||
|
|
||||||
spin_lock(&ubi->volumes_lock);
|
|
||||||
ubi->volumes[vol_id] = vol;
|
|
||||||
ubi->vol_count += 1;
|
|
||||||
spin_unlock(&ubi->volumes_lock);
|
|
||||||
|
|
||||||
ubi_volume_notify(ubi, vol, UBI_VOLUME_ADDED);
|
ubi_volume_notify(ubi, vol, UBI_VOLUME_ADDED);
|
||||||
self_check_volumes(ubi);
|
self_check_volumes(ubi);
|
||||||
return err;
|
return err;
|
||||||
|
@ -328,6 +329,10 @@ out_sysfs:
|
||||||
out_cdev:
|
out_cdev:
|
||||||
cdev_del(&vol->cdev);
|
cdev_del(&vol->cdev);
|
||||||
out_mapping:
|
out_mapping:
|
||||||
|
spin_lock(&ubi->volumes_lock);
|
||||||
|
ubi->volumes[vol_id] = NULL;
|
||||||
|
ubi->vol_count -= 1;
|
||||||
|
spin_unlock(&ubi->volumes_lock);
|
||||||
if (do_free)
|
if (do_free)
|
||||||
kfree(vol->eba_tbl);
|
kfree(vol->eba_tbl);
|
||||||
out_acc:
|
out_acc:
|
||||||
|
|
Loading…
Add table
Reference in a new issue