]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/2.6.38.8/ubifs-fix-a-rare-memory-leak-in-ro-to-rw-remounting-path.patch
Revert "Fixes for 6.9"
[thirdparty/kernel/stable-queue.git] / releases / 2.6.38.8 / ubifs-fix-a-rare-memory-leak-in-ro-to-rw-remounting-path.patch
CommitLineData
9e44e803
GKH
1From eaeee242c531cd4b0a4a46e8b5dd7ef504380c42 Mon Sep 17 00:00:00 2001
2From: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
3Date: Fri, 6 May 2011 17:08:56 +0300
4Subject: UBIFS: fix a rare memory leak in ro to rw remounting path
5
6From: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
7
8commit eaeee242c531cd4b0a4a46e8b5dd7ef504380c42 upstream.
9
10When re-mounting from R/O mode to R/W mode and the LEB count in the superblock
11is not up-to date, because for the underlying UBI volume became larger, we
12re-write the superblock. We allocate RAM for these purposes, but never free it.
13So this is a memory leak, although very rare one.
14
15Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
16Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
17
18---
19 fs/ubifs/sb.c | 3 ++-
20 fs/ubifs/super.c | 1 +
21 2 files changed, 3 insertions(+), 1 deletion(-)
22
23--- a/fs/ubifs/sb.c
24+++ b/fs/ubifs/sb.c
25@@ -475,7 +475,8 @@ failed:
26 * @c: UBIFS file-system description object
27 *
28 * This function returns a pointer to the superblock node or a negative error
29- * code.
30+ * code. Note, the user of this function is responsible of kfree()'ing the
31+ * returned superblock buffer.
32 */
33 struct ubifs_sb_node *ubifs_read_sb_node(struct ubifs_info *c)
34 {
35--- a/fs/ubifs/super.c
36+++ b/fs/ubifs/super.c
37@@ -1560,6 +1560,7 @@ static int ubifs_remount_rw(struct ubifs
38 }
39 sup->leb_cnt = cpu_to_le32(c->leb_cnt);
40 err = ubifs_write_sb_node(c, sup);
41+ kfree(sup);
42 if (err)
43 goto out;
44 }