]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
UBIFS: fix a rare memory leak in ro to rw remounting path
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Fri, 6 May 2011 14:08:56 +0000 (17:08 +0300)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 3 Jun 2011 01:34:38 +0000 (10:34 +0900)
commit eaeee242c531cd4b0a4a46e8b5dd7ef504380c42 upstream.

When re-mounting from R/O mode to R/W mode and the LEB count in the superblock
is not up-to date, because for the underlying UBI volume became larger, we
re-write the superblock. We allocate RAM for these purposes, but never free it.
So this is a memory leak, although very rare one.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
fs/ubifs/sb.c
fs/ubifs/super.c

index bf31b4729e51ce466560777a1e24bad90356311b..cad60b51f7c4a13d4e1fc89f89ab7c6237e504e4 100644 (file)
@@ -475,7 +475,8 @@ failed:
  * @c: UBIFS file-system description object
  *
  * This function returns a pointer to the superblock node or a negative error
- * code.
+ * code. Note, the user of this function is responsible of kfree()'ing the
+ * returned superblock buffer.
  */
 struct ubifs_sb_node *ubifs_read_sb_node(struct ubifs_info *c)
 {
index e20cb5a9aee5417b0ed6fa59a17144cd4a6f33e4..38749e76dda56ab1250477e550f3d4d43f18c5bf 100644 (file)
@@ -1560,6 +1560,7 @@ static int ubifs_remount_rw(struct ubifs_info *c)
                }
                sup->leb_cnt = cpu_to_le32(c->leb_cnt);
                err = ubifs_write_sb_node(c, sup);
+               kfree(sup);
                if (err)
                        goto out;
        }