Skip to content

Commit 35fccce

Browse files
josephhzakpm00
authored andcommitted
ocfs2: cancel dqi_sync_work before freeing oinfo
ocfs2_global_read_info() will initialize and schedule dqi_sync_work at the end, if error occurs after successfully reading global quota, it will trigger the following warning with CONFIG_DEBUG_OBJECTS_* enabled: ODEBUG: free active (active state 0) object: 00000000d8b0ce28 object type: timer_list hint: qsync_work_fn+0x0/0x16c This reports that there is an active delayed work when freeing oinfo in error handling, so cancel dqi_sync_work first. BTW, return status instead of -1 when .read_file_info fails. Link: https://syzkaller.appspot.com/bug?extid=f7af59df5d6b25f0febd Link: https://lkml.kernel.org/r/[email protected] Fixes: 171bf93 ("ocfs2: Periodic quota syncing") Signed-off-by: Joseph Qi <[email protected]> Reviewed-by: Heming Zhao <[email protected]> Reported-by: [email protected] Tested-by: [email protected] Cc: Mark Fasheh <[email protected]> Cc: Joel Becker <[email protected]> Cc: Junxiao Bi <[email protected]> Cc: Changwei Ge <[email protected]> Cc: Gang He <[email protected]> Cc: Jun Piao <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 33b525c commit 35fccce

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

fs/ocfs2/quota_local.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -692,14 +692,15 @@ static int ocfs2_local_read_info(struct super_block *sb, int type)
692692
int status;
693693
struct buffer_head *bh = NULL;
694694
struct ocfs2_quota_recovery *rec;
695-
int locked = 0;
695+
int locked = 0, global_read = 0;
696696

697697
info->dqi_max_spc_limit = 0x7fffffffffffffffLL;
698698
info->dqi_max_ino_limit = 0x7fffffffffffffffLL;
699699
oinfo = kmalloc(sizeof(struct ocfs2_mem_dqinfo), GFP_NOFS);
700700
if (!oinfo) {
701701
mlog(ML_ERROR, "failed to allocate memory for ocfs2 quota"
702702
" info.");
703+
status = -ENOMEM;
703704
goto out_err;
704705
}
705706
info->dqi_priv = oinfo;
@@ -712,6 +713,7 @@ static int ocfs2_local_read_info(struct super_block *sb, int type)
712713
status = ocfs2_global_read_info(sb, type);
713714
if (status < 0)
714715
goto out_err;
716+
global_read = 1;
715717

716718
status = ocfs2_inode_lock(lqinode, &oinfo->dqi_lqi_bh, 1);
717719
if (status < 0) {
@@ -782,10 +784,12 @@ static int ocfs2_local_read_info(struct super_block *sb, int type)
782784
if (locked)
783785
ocfs2_inode_unlock(lqinode, 1);
784786
ocfs2_release_local_quota_bitmaps(&oinfo->dqi_chunk);
787+
if (global_read)
788+
cancel_delayed_work_sync(&oinfo->dqi_sync_work);
785789
kfree(oinfo);
786790
}
787791
brelse(bh);
788-
return -1;
792+
return status;
789793
}
790794

791795
/* Write local info to quota file */

0 commit comments

Comments
 (0)