]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
ubi: Fix broken cleanup code in attach_by_scanning
authorJoe Hershberger <joe.hershberger@ni.com>
Mon, 8 Apr 2013 10:32:46 +0000 (10:32 +0000)
committerTom Rini <trini@ti.com>
Thu, 11 Apr 2013 19:52:54 +0000 (15:52 -0400)
The unwind code was not reversing operations correctly and was causing
a hang on any error condition.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
drivers/mtd/ubi/build.c
drivers/mtd/ubi/wl.c

index d144ac29bc5f21c1ac84c1932802f6579a796565..a708162e43a826846584cf1440a0d783bbd4a53a 100644 (file)
@@ -478,19 +478,19 @@ static int attach_by_scanning(struct ubi_device *ubi)
 
        err = ubi_eba_init_scan(ubi, si);
        if (err)
-               goto out_wl;
+               goto out_vtbl;
 
        err = ubi_wl_init_scan(ubi, si);
        if (err)
-               goto out_vtbl;
+               goto out_eba;
 
        ubi_scan_destroy_si(si);
        return 0;
 
+out_eba:
+       ubi_eba_close(ubi);
 out_vtbl:
        vfree(ubi->vtbl);
-out_wl:
-       ubi_wl_close(ubi);
 out_si:
        ubi_scan_destroy_si(si);
        return err;
index 88b867a0c173a754a7a173e70a736ca08bb87014..d1ba722cb58461815eb5eb20b65f88d81532b1a5 100644 (file)
@@ -1538,6 +1538,7 @@ int ubi_wl_init_scan(struct ubi_device *ubi, struct ubi_scan_info *si)
        if (ubi->avail_pebs < WL_RESERVED_PEBS) {
                ubi_err("no enough physical eraseblocks (%d, need %d)",
                        ubi->avail_pebs, WL_RESERVED_PEBS);
+               err = -ENOSPC;
                goto out_free;
        }
        ubi->avail_pebs -= WL_RESERVED_PEBS;