From 21ac738ede0b49004b53b4a44fe3df7bb4a78280 Mon Sep 17 00:00:00 2001 From: Chengguang Xu Date: Sun, 29 Jul 2018 15:51:54 -0400 Subject: [PATCH] ext4: check allocation failure when duplicating "data" in ext4_remount() There is no check for allocation failure when duplicating "data" in ext4_remount(). Check for failure and return error -ENOMEM in this case. Signed-off-by: Chengguang Xu Signed-off-by: Theodore Ts'o Reviewed-by: Andreas Dilger --- fs/ext4/super.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 3e64d8d..d4a218b 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -5101,6 +5101,9 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data) #endif char *orig_data = kstrdup(data, GFP_KERNEL); + if (data && !orig_data) + return -ENOMEM; + /* Store the original options */ old_sb_flags = sb->s_flags; old_opts.s_mount_opt = sbi->s_mount_opt; -- 2.7.4