Skip to contentSkip to conversation

ocfs2: cancel dqi_sync_work before freeing oinfo

PATCH Superseded Joseph Qi 2 participants 3 messages Sep 4, 2024 OCFS2

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Joseph Qi

author maintainer
#0 lore raw

PATCH 1/1 ocfs2: cancel dqi_sync_work before freeing oinfo

ocfs2_global_read_info() will schedule dqi_sync_work. So any error occurs after it, we have to cancel this delayed work first before freeing oinfo, otherwise 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

Reported-by [email protected]
Fixes 171bf93ce11f ("ocfs2: Periodic quota syncing")
---
 fs/ocfs2/quota_local.c | 1 +
 1 file changed, 1 insertion(+)
fs/ocfs2/quota_local.c +1 -0
index 8ce462c64c51..ebe0dbc8db4a 100644
@@ -782,6 +782,7 @@ static int ocfs2_local_read_info(struct super_block *sb, int type)
 		if (locked)
 			ocfs2_inode_unlock(lqinode, 1);
 		ocfs2_release_local_quota_bitmaps(&oinfo->dqi_chunk);
+		cancel_delayed_work_sync(&oinfo->dqi_sync_work);
 		kfree(oinfo);
 	}
 	brelse(bh);
Signature · 1 line
2.39.3
reviewer
#1 lore raw
Quoted 22 lines · Joseph Qi

ocfs2_global_read_info() will schedule dqi_sync_work. So any error occurs after it, we have to cancel this delayed work first before freeing oinfo, otherwise 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

Reported-by [email protected]
Fixes 171bf93ce11f ("ocfs2: Periodic quota syncing")
---
  fs/ocfs2/quota_local.c | 1 +
  1 file changed, 1 insertion(+)
fs/ocfs2/quota_local.c +0 -0
index 8ce462c64c51..ebe0dbc8db4a 100644

fs/ocfs2/quota_local.c static int ocfs2_local_read_info(struct super_block *sb, int type) · line 788

Quoted 7 lines
fs/ocfs2/quota_local.c +1 -0
@@ -782,6 +782,7 @@ static int ocfs2_local_read_info(struct super_block *sb, int type)
  		if (locked)
  			ocfs2_inode_unlock(lqinode, 1);
  		ocfs2_release_local_quota_bitmaps(&oinfo->dqi_chunk);
+		cancel_delayed_work_sync(&oinfo->dqi_sync_work);
  		kfree(oinfo);
  	}
  	brelse(bh);

In my view, there is one problem:
If ocfs2_global_read_info() returns error before ->dqi_sync_work is initialized, above code will trigger wild pointer error.

-Heming

author maintainer
#2 lore raw
Quoted 18 lines · Heming Zhao
Quoted 17 lines · Joseph Qi

ocfs2_global_read_info() will schedule dqi_sync_work. So any error occurs after it, we have to cancel this delayed work first before freeing oinfo, otherwise 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

Reported-by [email protected]
Fixes 171bf93ce11f ("ocfs2: Periodic quota syncing")

---
  fs/ocfs2/quota_local.c | 1 +

  1 file changed, 1 insertion(+)
Quoted 17 lines

fs/ocfs2/quota_local.c static int ocfs2_local_read_info(struct super_block *sb, int type) · line 788

Quoted 12 lines
fs/ocfs2/quota_local.c +1 -0
index 8ce462c64c51..ebe0dbc8db4a 100644
@@ -782,6 +782,7 @@ static int ocfs2_local_read_info(struct super_block *sb, int type)
           if (locked)
               ocfs2_inode_unlock(lqinode, 1);
           ocfs2_release_local_quota_bitmaps(&oinfo->dqi_chunk);
+        cancel_delayed_work_sync(&oinfo->dqi_sync_work);
           kfree(oinfo);
       }
       brelse(bh);

In my view, there is one problem:
If ocfs2_global_read_info() returns error before ->dqi_sync_work is initialized, above code will trigger wild pointer error.

You're right. Will update and send v2.

Thanks,
Joseph