aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/super.c
diff options
context:
space:
mode:
authorEric Sandeen <sandeen@redhat.com>2010-02-15 20:17:55 -0500
committerTheodore Ts'o <tytso@mit.edu>2010-02-15 20:17:55 -0500
commit15121c18a22ae483279f76dc9e554334b800d0f7 (patch)
tree50861d9444cd21945a6086fa03c2bdd1a7f8c354 /fs/ext4/super.c
parenta1de02dccf906faba2ee2d99cac56799bda3b96a (diff)
ext4: Fix optional-arg mount options
We have 2 mount options, "barrier" and "auto_da_alloc" which may or may not take a 1/0 argument. This causes the ext4 superblock mount code to subtract uninitialized pointers and pass the result to kmalloc, which results in very noisy failures. Per Ted's suggestion, initialize the args struct so that we know whether match_token() found an argument for the option, and skip match_int() if not. Also, return error (0) from parse_options if we thought we found an argument, but match_int() Fails. Reported-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/super.c')
-rw-r--r--fs/ext4/super.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 735c20d5fd56..68a55dffb360 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -1229,6 +1229,11 @@ static int parse_options(char *options, struct super_block *sb,
1229 if (!*p) 1229 if (!*p)
1230 continue; 1230 continue;
1231 1231
1232 /*
1233 * Initialize args struct so we know whether arg was
1234 * found; some options take optional arguments.
1235 */
1236 args[0].to = args[0].from = 0;
1232 token = match_token(p, tokens, args); 1237 token = match_token(p, tokens, args);
1233 switch (token) { 1238 switch (token) {
1234 case Opt_bsd_df: 1239 case Opt_bsd_df:
@@ -1518,10 +1523,11 @@ set_qf_format:
1518 clear_opt(sbi->s_mount_opt, BARRIER); 1523 clear_opt(sbi->s_mount_opt, BARRIER);
1519 break; 1524 break;
1520 case Opt_barrier: 1525 case Opt_barrier:
1521 if (match_int(&args[0], &option)) { 1526 if (args[0].from) {
1522 set_opt(sbi->s_mount_opt, BARRIER); 1527 if (match_int(&args[0], &option))
1523 break; 1528 return 0;
1524 } 1529 } else
1530 option = 1; /* No argument, default to 1 */
1525 if (option) 1531 if (option)
1526 set_opt(sbi->s_mount_opt, BARRIER); 1532 set_opt(sbi->s_mount_opt, BARRIER);
1527 else 1533 else
@@ -1594,10 +1600,11 @@ set_qf_format:
1594 set_opt(sbi->s_mount_opt,NO_AUTO_DA_ALLOC); 1600 set_opt(sbi->s_mount_opt,NO_AUTO_DA_ALLOC);
1595 break; 1601 break;
1596 case Opt_auto_da_alloc: 1602 case Opt_auto_da_alloc:
1597 if (match_int(&args[0], &option)) { 1603 if (args[0].from) {
1598 clear_opt(sbi->s_mount_opt, NO_AUTO_DA_ALLOC); 1604 if (match_int(&args[0], &option))
1599 break; 1605 return 0;
1600 } 1606 } else
1607 option = 1; /* No argument, default to 1 */
1601 if (option) 1608 if (option)
1602 clear_opt(sbi->s_mount_opt, NO_AUTO_DA_ALLOC); 1609 clear_opt(sbi->s_mount_opt, NO_AUTO_DA_ALLOC);
1603 else 1610 else