Commit b4f2a457 authored by Jan Kara's avatar Jan Kara Committed by sanglipeng
Browse files

quota: Properly disable quotas when add_dquot_ref() fails

stable inclusion
from stable-v5.10.192
commit 8a4f4d47b82f61138214b74c309270fafbeb4ba2
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I933RF

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=8a4f4d47b82f61138214b74c309270fafbeb4ba2



--------------------------------

[ Upstream commit 6a4e3363 ]

When add_dquot_ref() fails (usually due to IO error or ENOMEM), we want
to disable quotas we are trying to enable. However dquot_disable() call
was passed just the flags we are enabling so in case flags ==
DQUOT_USAGE_ENABLED dquot_disable() call will just fail with EINVAL
instead of properly disabling quotas. Fix the problem by always passing
DQUOT_LIMITS_ENABLED | DQUOT_USAGE_ENABLED to dquot_disable() in this
case.

Reported-and-tested-by: default avatarYe Bin <yebin10@huawei.com>
Reported-by: default avatar <syzbot+e633c79ceaecbf479854@syzkaller.appspotmail.com>
Signed-off-by: default avatarJan Kara <jack@suse.cz>
Message-Id: <20230605140731.2427629-2-yebin10@huawei.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarsanglipeng <sanglipeng1@jd.com>
parent 6288e0ff
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment