Skip to content

Commit b9d8905

Browse files
mikulas-patockajankara
authored andcommitted
reiserfs: check kstrdup failure
Check out-of-memory failure of the kstrdup option. Note that the argument "arg" may be NULL (in that case kstrup returns NULL), so out of memory condition happened if arg was non-NULL and kstrdup returned NULL. The patch also changes the call to replace_mount_options - if we didn't pass any filesystem-specific options, we don't call replace_mount_options (thus we don't erase existing reported options). Note that to properly report options after remount, the reiserfs filesystem should implement the show_options method. Without the show_options method, options changed with remount replace existing options. Signed-off-by: Mikulas Patocka <[email protected]> Signed-off-by: Jan Kara <[email protected]>
1 parent 7888824 commit b9d8905

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

fs/reiserfs/super.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1393,14 +1393,18 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg)
13931393
unsigned long safe_mask = 0;
13941394
unsigned int commit_max_age = (unsigned int)-1;
13951395
struct reiserfs_journal *journal = SB_JOURNAL(s);
1396-
char *new_opts = kstrdup(arg, GFP_KERNEL);
1396+
char *new_opts;
13971397
int err;
13981398
char *qf_names[REISERFS_MAXQUOTAS];
13991399
unsigned int qfmt = 0;
14001400
#ifdef CONFIG_QUOTA
14011401
int i;
14021402
#endif
14031403

1404+
new_opts = kstrdup(arg, GFP_KERNEL);
1405+
if (arg && !new_opts)
1406+
return -ENOMEM;
1407+
14041408
sync_filesystem(s);
14051409
reiserfs_write_lock(s);
14061410

@@ -1546,7 +1550,8 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg)
15461550
}
15471551

15481552
out_ok_unlocked:
1549-
replace_mount_options(s, new_opts);
1553+
if (new_opts)
1554+
replace_mount_options(s, new_opts);
15501555
return 0;
15511556

15521557
out_err_unlock:

0 commit comments

Comments
 (0)