]>
Commit | Line | Data |
---|---|---|
375caec0 GKH |
1 | From 01d6e08711bf90bc4d7ead14a93a0cbd73b1896a Mon Sep 17 00:00:00 2001 |
2 | From: Mikulas Patocka <mikulas@twibright.com> | |
3 | Date: Tue, 24 May 2016 22:48:33 +0200 | |
4 | Subject: affs: fix remount failure when there are no options changed | |
5 | ||
6 | From: Mikulas Patocka <mikulas@twibright.com> | |
7 | ||
8 | commit 01d6e08711bf90bc4d7ead14a93a0cbd73b1896a upstream. | |
9 | ||
10 | Commit c8f33d0bec99 ("affs: kstrdup() memory handling") checks if the | |
11 | kstrdup function returns NULL due to out-of-memory condition. | |
12 | ||
13 | However, if we are remounting a filesystem with no change to | |
14 | filesystem-specific options, the parameter data is NULL. In this case, | |
15 | kstrdup returns NULL (because it was passed NULL parameter), although no | |
16 | out of memory condition exists. The mount syscall then fails with | |
17 | ENOMEM. | |
18 | ||
19 | This patch fixes the bug. We fail with ENOMEM only if data is non-NULL. | |
20 | ||
21 | The patch also changes the call to replace_mount_options - if we didn't | |
22 | pass any filesystem-specific options, we don't call | |
23 | replace_mount_options (thus we don't erase existing reported options). | |
24 | ||
25 | Fixes: c8f33d0bec99 ("affs: kstrdup() memory handling") | |
26 | Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> | |
27 | Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> | |
28 | Signed-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; |