From: Niu YaWei Date: Sat, 16 Apr 2005 22:25:47 +0000 (-0700) Subject: [PATCH] quota: possible bug in quota format v2 support X-Git-Tag: v2.6.12-rc3~113 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e821d94d34af23a31a16ead78e8b685b750c8c3d;p=linux-2.6 [PATCH] quota: possible bug in quota format v2 support Don't put root block of quota tree to the free list (when quota file is completely empty). That should not actually happen anyway (somebody should get accounted for the filesystem root and so quota file should never be empty) but better prevent it here than solve magical quota file corruption. Signed-off-by: Jan Kara Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/fs/quota_v2.c b/fs/quota_v2.c index 19bdb7b86c..7afcbb1b93 100644 --- a/fs/quota_v2.c +++ b/fs/quota_v2.c @@ -503,7 +503,8 @@ static int remove_tree(struct dquot *dquot, uint *blk, int depth) int i; ref[GETIDINDEX(dquot->dq_id, depth)] = cpu_to_le32(0); for (i = 0; i < V2_DQBLKSIZE && !buf[i]; i++); /* Block got empty? */ - if (i == V2_DQBLKSIZE) { + /* Don't put the root block into the free block list */ + if (i == V2_DQBLKSIZE && *blk != V2_DQTREEOFF) { put_free_dqblk(sb, type, buf, *blk); *blk = 0; }