]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
UBI: fix dereference after kfree
authorFlorin Malita <fmalita@gmail.com>
Thu, 3 May 2007 15:49:57 +0000 (11:49 -0400)
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Wed, 18 Jul 2007 13:52:22 +0000 (16:52 +0300)
Coverity (CID 1614) spotted new_seb being dereferenced after kfree() in
create_vtbl's write_error path.

Signed-off-by: Florin Malita <fmalita@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
drivers/mtd/ubi/vtbl.c

index b6fd6bbd941e63782d25aadad09b0e136c4d13fe..83236c31c89232a0a944558271681da7bfd31064 100644 (file)
@@ -317,14 +317,13 @@ retry:
        return err;
 
 write_error:
-       kfree(new_seb);
-       /* May be this physical eraseblock went bad, try to pick another one */
-       if (++tries <= 5) {
+       /* Maybe this physical eraseblock went bad, try to pick another one */
+       if (++tries <= 5)
                err = ubi_scan_add_to_list(si, new_seb->pnum, new_seb->ec,
                                           &si->corr);
-               if (!err)
-                       goto retry;
-       }
+       kfree(new_seb);
+       if (!err)
+               goto retry;
 out_free:
        ubi_free_vid_hdr(ubi, vid_hdr);
        return err;