summaryrefslogtreecommitdiffstats
path: root/fs/quota
diff options
context:
space:
mode:
authorChengguang Xu <cgxu519@mykernel.net>2019-10-08 22:50:59 +0800
committerJan Kara <jack@suse.cz>2019-10-08 17:26:18 +0200
commita6810312b835ed927edaef0e96217c02084c7f4f (patch)
tree58db19afa3c0d4c9198a643998e07b09c782467b /fs/quota
parent24fc755f56b15bf3215c0d0b8b62d7204f369bab (diff)
downloadtalos-op-linux-a6810312b835ed927edaef0e96217c02084c7f4f.tar.gz
talos-op-linux-a6810312b835ed927edaef0e96217c02084c7f4f.zip
quota: check quota type in early stage
Check quota type in early stage so we can avoid many unncessary operations when the type is wrong. Link: https://lore.kernel.org/r/20191008145059.21402-1-cgxu519@mykernel.net Signed-off-by: Chengguang Xu <cgxu519@mykernel.net> Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/quota')
-rw-r--r--fs/quota/quota.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/fs/quota/quota.c b/fs/quota/quota.c
index cb13fb76dbee..5444d3c4d93f 100644
--- a/fs/quota/quota.c
+++ b/fs/quota/quota.c
@@ -60,8 +60,6 @@ static int quota_sync_all(int type)
{
int ret;
- if (type >= MAXQUOTAS)
- return -EINVAL;
ret = security_quotactl(Q_SYNC, type, 0, NULL);
if (!ret)
iterate_supers(quota_sync_one, &type);
@@ -686,8 +684,6 @@ static int do_quotactl(struct super_block *sb, int type, int cmd, qid_t id,
{
int ret;
- if (type >= MAXQUOTAS)
- return -EINVAL;
type = array_index_nospec(type, MAXQUOTAS);
/*
* Quota not supported on this fs? Check this before s_quota_types
@@ -831,6 +827,9 @@ int kernel_quotactl(unsigned int cmd, const char __user *special,
cmds = cmd >> SUBCMDSHIFT;
type = cmd & SUBCMDMASK;
+ if (type >= MAXQUOTAS)
+ return -EINVAL;
+
/*
* As a special case Q_SYNC can be called without a specific device.
* It will iterate all superblocks that have quota enabled and call
OpenPOWER on IntegriCloud