ext4: fix reserved_clusters_store()
Subsystems (2)
PATCH 1/1 ext4: fix reserved_clusters_store()
The test if kstrtoull() failed is reversed so we can't set cluster_store any more.
Fixes 76d33bca5581 ("ext4: refactor sysfs support code")
Signed-off-by Dan Carpenter <[email protected]>
fs/ext4/sysfs.c +3 -1
@@ -100,7 +100,9 @@ static ssize_t reserved_clusters_store(struct ext4_attr *a,int ret; ret =kstrtoull (skip_spaces (buf),0 , &val); -if (!ret || val >= clusters) +if (ret) +return ret; +if (val >= clusters)return -EINVAL ;atomic64_set (&sbi->s_resv_clusters, val);
Theodore Ts'o
maintainerQuoted 5 lines · Dan Carpenter
The test if
kstrtoull()failed is reversed so we can't setcluster_storeany more.Fixes 76d33bca5581 ("ext4: refactor sysfs support code")Signed-off-by Dan Carpenter <[email protected]>
Thanks, this should already be fixed in the ext4.git tree.
- Ted
commit f5b877c913026b9c5d4d1ac2916eff46c49b37a0
Author: Chao Yu <[email protected]> Date: Fri Jun 23 01:08:22 2017 -0400
ext4: check return value of kstrtoull correctly in reserved_clusters_store
kstrtoull returns 0 on success, however, in reserved_clusters_store we will return -EINVAL if kstrtoull returns 0, it makes us fail to update reserved_clusters value through sysfs.
Fixes 76d33bca5581b1dd5c3157fa168db849a784ada4
Cc [email protected] # 4.4
Signed-off-by Chao Yu <[email protected]>
Signed-off-by Miao Xie <[email protected]>
Signed-off-by Theodore Ts'o <[email protected]>
fs/ext4/sysfs.c +1 -1
@@ -100,7 +100,7 @@ static ssize_t reserved_clusters_store(struct ext4_attr *a,int ret; ret =kstrtoull (skip_spaces (buf),0 , &val); -if (!ret || val >= clusters) +if (ret || val >= clusters)return -EINVAL ;atomic64_set (&sbi->s_resv_clusters, val);