Skip to content

Commit e9d4709

Browse files
committed
reiserfs: Fix memory leak in reiserfs_parse_options()
When a usrjquota or grpjquota mount option is used multiple times, we will leak memory allocated for the file name. Make sure the last setting is used and all the previous ones are properly freed. Reported-by: syzbot+c9e294bbe0333a6b7640@syzkaller.appspotmail.com Signed-off-by: Jan Kara <jack@suse.cz>
1 parent 256ccb9 commit e9d4709

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

‎fs/reiserfs/super.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,6 +1258,10 @@ static int reiserfs_parse_options(struct super_block *s,
12581258
"turned on.");
12591259
return 0;
12601260
}
1261+
if (qf_names[qtype] !=
1262+
REISERFS_SB(s)->s_qf_names[qtype])
1263+
kfree(qf_names[qtype]);
1264+
qf_names[qtype] = NULL;
12611265
if (*arg) { /* Some filename specified? */
12621266
if (REISERFS_SB(s)->s_qf_names[qtype]
12631267
&& strcmp(REISERFS_SB(s)->s_qf_names[qtype],
@@ -1287,10 +1291,6 @@ static int reiserfs_parse_options(struct super_block *s,
12871291
else
12881292
*mount_options |= 1 << REISERFS_GRPQUOTA;
12891293
} else {
1290-
if (qf_names[qtype] !=
1291-
REISERFS_SB(s)->s_qf_names[qtype])
1292-
kfree(qf_names[qtype]);
1293-
qf_names[qtype] = NULL;
12941294
if (qtype == USRQUOTA)
12951295
*mount_options &= ~(1 << REISERFS_USRQUOTA);
12961296
else

0 commit comments

Comments
 (0)