]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.4.13/affs-fix-remount-failure-when-there-are-no-options-changed.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.4.13 / affs-fix-remount-failure-when-there-are-no-options-changed.patch
CommitLineData
375caec0
GKH
1From 01d6e08711bf90bc4d7ead14a93a0cbd73b1896a Mon Sep 17 00:00:00 2001
2From: Mikulas Patocka <mikulas@twibright.com>
3Date: Tue, 24 May 2016 22:48:33 +0200
4Subject: affs: fix remount failure when there are no options changed
5
6From: Mikulas Patocka <mikulas@twibright.com>
7
8commit 01d6e08711bf90bc4d7ead14a93a0cbd73b1896a upstream.
9
10Commit c8f33d0bec99 ("affs: kstrdup() memory handling") checks if the
11kstrdup function returns NULL due to out-of-memory condition.
12
13However, if we are remounting a filesystem with no change to
14filesystem-specific options, the parameter data is NULL. In this case,
15kstrdup returns NULL (because it was passed NULL parameter), although no
16out of memory condition exists. The mount syscall then fails with
17ENOMEM.
18
19This patch fixes the bug. We fail with ENOMEM only if data is non-NULL.
20
21The patch also changes the call to replace_mount_options - if we didn't
22pass any filesystem-specific options, we don't call
23replace_mount_options (thus we don't erase existing reported options).
24
25Fixes: c8f33d0bec99 ("affs: kstrdup() memory handling")
26Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
27Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
28Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
29
30---
31 fs/affs/super.c | 5 +++--
32 1 file changed, 3 insertions(+), 2 deletions(-)
33
34--- a/fs/affs/super.c
35+++ b/fs/affs/super.c
36@@ -528,7 +528,7 @@ affs_remount(struct super_block *sb, int
37 char *prefix = NULL;
38
39 new_opts = kstrdup(data, GFP_KERNEL);
40- if (!new_opts)
41+ if (data && !new_opts)
42 return -ENOMEM;
43
44 pr_debug("%s(flags=0x%x,opts=\"%s\")\n", __func__, *flags, data);
45@@ -546,7 +546,8 @@ affs_remount(struct super_block *sb, int
46 }
47
48 flush_delayed_work(&sbi->sb_work);
49- replace_mount_options(sb, new_opts);
50+ if (new_opts)
51+ replace_mount_options(sb, new_opts);
52
53 sbi->s_flags = mount_flags;
54 sbi->s_mode = mode;