1 ext4: better error handling for kstrdup() failures
3 From: Taesoo Kim <tsgatesv@gmail.com>
5 Upon memory pressure, kstrdup() might fail and correctly
6 handle memory error, although current implementation do not
9 NOTE: fortunately the correct impl works, other than a corner case
10 where kstrdup() fails and kzalloc() succeeds; it might record 'NULL'
13 Signed-off-by: Taesoo Kim <tsgatesv@gmail.com>
14 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
16 fs/ext4/super.c | 8 +++++++-
17 1 file changed, 7 insertions(+), 1 deletion(-)
19 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
20 index e061e66..e2a609c 100644
23 @@ -3408,7 +3408,7 @@ static int ext4_reserve_clusters(struct ext4_sb_info *sbi, ext4_fsblk_t count)
25 static int ext4_fill_super(struct super_block *sb, void *data, int silent)
27 - char *orig_data = kstrdup(data, GFP_KERNEL);
29 struct buffer_head *bh;
30 struct ext4_super_block *es = NULL;
31 struct ext4_sb_info *sbi;
32 @@ -3431,6 +3431,10 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
33 unsigned int journal_ioprio = DEFAULT_JOURNAL_IOPRIO;
34 ext4_group_t first_not_zeroed;
36 + orig_data = kstrdup(data, GFP_KERNEL);
40 sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
43 @@ -4843,6 +4847,8 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
46 char *orig_data = kstrdup(data, GFP_KERNEL);
50 /* Store the original options */
51 old_sb_flags = sb->s_flags;