diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c index 85d54f37e28f..264734c4b892 100644 --- a/drivers/mtd/ubi/build.c +++ b/drivers/mtd/ubi/build.c @@ -986,12 +986,6 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, goto out_free; } - if (ubi->autoresize_vol_id != -1) { - err = autoresize(ubi, ubi->autoresize_vol_id); - if (err) - goto out_detach; - } - /* Make device "available" before it becomes accessible via sysfs */ ubi_devices[ubi_num] = ubi; @@ -1039,9 +1033,17 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, wake_up_process(ubi->bgt_thread); spin_unlock(&ubi->wl_lock); + if (ubi->autoresize_vol_id != -1) { + err = autoresize(ubi, ubi->autoresize_vol_id); + if (err) + goto out_kthread; + } + ubi_notify_all(ubi, UBI_VOLUME_ADDED, NULL); return ubi_num; +out_kthread: + kthread_stop(ubi->bgt_thread); out_debugfs: ubi_debugfs_exit_dev(ubi); out_uif: