From: zhangyi (F) Date: Wed, 1 Nov 2017 10:40:45 +0000 (+0800) Subject: quota: fix potential infinite loop X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=dd5f6279732e8885061d7455b9d86fdcfdf7f183;p=linux.git quota: fix potential infinite loop 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) Signed-off-by: Jan Kara --- diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index 50b0556a124f2..f68397923ebb5 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c @@ -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); }