]>
Commit | Line | Data |
---|---|---|
9e44e803 GKH |
1 | From eaeee242c531cd4b0a4a46e8b5dd7ef504380c42 Mon Sep 17 00:00:00 2001 |
2 | From: Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | |
3 | Date: Fri, 6 May 2011 17:08:56 +0300 | |
4 | Subject: UBIFS: fix a rare memory leak in ro to rw remounting path | |
5 | ||
6 | From: Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | |
7 | ||
8 | commit eaeee242c531cd4b0a4a46e8b5dd7ef504380c42 upstream. | |
9 | ||
10 | When re-mounting from R/O mode to R/W mode and the LEB count in the superblock | |
11 | is not up-to date, because for the underlying UBI volume became larger, we | |
12 | re-write the superblock. We allocate RAM for these purposes, but never free it. | |
13 | So this is a memory leak, although very rare one. | |
14 | ||
15 | Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | |
16 | Signed-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 | } |