Skip to contentSkip to conversation

ext4: fix reserved_clusters_store()

PATCH In review Dan Carpenter 2 participants 2 messages Jun 23, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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")
fs/ext4/sysfs.c +3 -1
index d74dc5f81a04..5d543523f479 100644
@@ -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);
maintainer
#1 lore raw
Quoted 5 lines · Dan Carpenter

The test if kstrtoull() failed is reversed so we can't set cluster_store any more.

Fixes 76d33bca5581 ("ext4: refactor sysfs support code")

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
fs/ext4/sysfs.c +1 -1
index d74dc5f81a04..48c7a7d55ed3 100644
@@ -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);