Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c3a1f5ba authored by Jan Kara's avatar Jan Kara Committed by Greg Kroah-Hartman
Browse files

quota: Properly disable quotas when add_dquot_ref() fails



[ Upstream commit 6a4e3363792e30177cc3965697e34ddcea8b900b ]

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>
parent dd445ebb
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -2415,7 +2415,8 @@ int dquot_load_quota_sb(struct super_block *sb, int type, int format_id,

	error = add_dquot_ref(sb, type);
	if (error)
		dquot_disable(sb, type, flags);
		dquot_disable(sb, type,
			      DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED);

	return error;
out_fmt: