]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
quota: fix potential infinite loop
authorzhangyi (F) <yi.zhang@huawei.com>
Wed, 1 Nov 2017 10:40:45 +0000 (18:40 +0800)
committerJan Kara <jack@suse.cz>
Wed, 1 Nov 2017 13:42:57 +0000 (14:42 +0100)
In dquot_writeback_dquots(), we write back dquot from dirty dquots
list. There is a potential infinite loop if ->write_dquot() failure
and forget remove dquot from the list. This patch clear dirty bit
anyway to avoid it.

Signed-off-by: zhangyi (F) <yi.zhang@huawei.com>
Signed-off-by: Jan Kara <jack@suse.cz>
fs/quota/dquot.c

index 50b0556a124f2508531ce9e6fc61721aeb179cc8..f68397923ebb57fe3ac13a36944300a0b3396b50 100644 (file)
@@ -644,8 +644,15 @@ int dquot_writeback_dquots(struct super_block *sb, int type)
                        spin_unlock(&dq_list_lock);
                        dqstats_inc(DQST_LOOKUPS);
                        err = sb->dq_op->write_dquot(dquot);
-                       if (!ret && err)
-                               ret = err;
+                       if (err) {
+                               /*
+                                * Clear dirty bit anyway to avoid infinite
+                                * loop here.
+                                */
+                               clear_dquot_dirty(dquot);
+                               if (!ret)
+                                       ret = err;
+                       }
                        dqput(dquot);
                        spin_lock(&dq_list_lock);
                }