Simplify error flow in thpsize_shmem_enabled_store().
Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
---
mm/shmem.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/mm/shmem.c b/mm/shmem.c
index e3e05bbb6db2..c6ea45d542d2 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -5601,7 +5601,7 @@ static ssize_t thpsize_shmem_enabled_store(struct kobject *kobj,
const char *buf, size_t count)
{
int order = to_thpsize(kobj)->order;
- ssize_t ret = count;
+ int err;
if (sysfs_streq(buf, "always")) {
spin_lock(&huge_shmem_orders_lock);
@@ -5644,16 +5644,14 @@ static ssize_t thpsize_shmem_enabled_store(struct kobject *kobj,
clear_bit(order, &huge_shmem_orders_madvise);
spin_unlock(&huge_shmem_orders_lock);
} else {
- ret = -EINVAL;
+ return -EINVAL;
}
- if (ret > 0) {
- int err = start_stop_khugepaged();
+ err = start_stop_khugepaged();
+ if (err)
+ return err;
- if (err)
- ret = err;
- }
- return ret;
+ return count;
}
struct kobj_attribute thpsize_shmem_enabled_attr =
--
2.30.0