Skip to content

Commit 4408ea4

Browse files
committed
quota: Fix possible oops in __dquot_initialize()
When quotaon(8) races with __dquot_initialize() or dqget() fails because of EIO, ENOSPC, or similar error, we could possibly dereference NULL pointer in inode->i_dquot[cnt]. Add proper checking. Reported-by: Dmitry Monakhov <dmonakhov@gmail.com> Signed-off-by: Jan Kara <jack@suse.cz>
1 parent a4c18ad commit 4408ea4

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

‎fs/quota/dquot.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,6 +1386,9 @@ static void __dquot_initialize(struct inode *inode, int type)
13861386
/* Avoid races with quotaoff() */
13871387
if (!sb_has_quota_active(sb, cnt))
13881388
continue;
1389+
/* We could race with quotaon or dqget() could have failed */
1390+
if (!got[cnt])
1391+
continue;
13891392
if (!inode->i_dquot[cnt]) {
13901393
inode->i_dquot[cnt] = got[cnt];
13911394
got[cnt] = NULL;

0 commit comments

Comments
 (0)