diff mbox series

[v2] ext4: Check allocation failure when duplicating "data" in ext4_remount()

Message ID 20180620054612.7747-1-cgxu519@gmx.com
State Accepted, archived
Headers show
Series [v2] ext4: Check allocation failure when duplicating "data" in ext4_remount() | expand

Commit Message

cgxu519 June 20, 2018, 5:46 a.m. UTC
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 <cgxu519@gmx.com>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
---
v2:
- Modify changelog for easy understading.

 fs/ext4/super.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Theodore Ts'o July 23, 2018, 7:53 p.m. UTC | #1
On Wed, Jun 20, 2018 at 01:46:12PM +0800, Chengguang Xu wrote:
> 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 <cgxu519@gmx.com>
> Reviewed-by: Andreas Dilger <adilger@dilger.ca>

Applied, thanks.

					- Ted
diff mbox series

Patch

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 0c4c2201b3aa..f9c3da513cae 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -5014,6 +5014,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;