summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2018-04-14 03:35:59 -0400
committerKent Overstreet <kent.overstreet@gmail.com>2018-04-14 03:35:59 -0400
commit3b7c824e9330a640312fce1b04537c684c1d602c (patch)
treeb86e8e86d09375e4c87f4ee7c1a4dc779a28ac1f
parente93d87ea703656a881f6dc818e6d88b080eea7f2 (diff)
bcachefs: strip whitespace when setting options via sysfs
-rw-r--r--fs/bcachefs/sysfs.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/fs/bcachefs/sysfs.c b/fs/bcachefs/sysfs.c
index e8089db9a1bd..4da1b3f36366 100644
--- a/fs/bcachefs/sysfs.c
+++ b/fs/bcachefs/sysfs.c
@@ -531,9 +531,16 @@ STORE(bch2_fs_opts_dir)
struct bch_fs *c = container_of(kobj, struct bch_fs, opts_dir);
const struct bch_option *opt = container_of(attr, struct bch_option, attr);
int ret, id = opt - bch2_opt_table;
+ char *tmp;
u64 v;
- ret = bch2_opt_parse(c, opt, buf, &v);
+ tmp = kstrdup(buf, GFP_KERNEL);
+ if (!tmp)
+ return -ENOMEM;
+
+ ret = bch2_opt_parse(c, opt, strim(tmp), &v);
+ kfree(tmp);
+
if (ret < 0)
return ret;