1 From 77fa100f27475d08a569b9d51c17722130f089e7 Mon Sep 17 00:00:00 2001
2 From: Tony Asleson <tasleson@redhat.com>
3 Date: Wed, 6 Sep 2017 14:25:57 +0800
4 Subject: bcache: Correct return value for sysfs attach errors
6 From: Tony Asleson <tasleson@redhat.com>
8 commit 77fa100f27475d08a569b9d51c17722130f089e7 upstream.
10 If you encounter any errors in bch_cached_dev_attach it will return
11 a negative error code. The variable 'v' which stores the result is
12 unsigned, thus user space sees a very large value returned for bytes
13 written which can cause incorrect user space behavior. Utilize 1
14 signed variable to use throughout the function to preserve error return
17 Signed-off-by: Tony Asleson <tasleson@redhat.com>
18 Acked-by: Coly Li <colyli@suse.de>
19 Signed-off-by: Jens Axboe <axboe@kernel.dk>
20 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
23 drivers/md/bcache/sysfs.c | 4 ++--
24 1 file changed, 2 insertions(+), 2 deletions(-)
26 --- a/drivers/md/bcache/sysfs.c
27 +++ b/drivers/md/bcache/sysfs.c
28 @@ -191,7 +191,7 @@ STORE(__cached_dev)
30 struct cached_dev *dc = container_of(kobj, struct cached_dev,
35 struct kobj_uevent_env *env;
37 @@ -226,7 +226,7 @@ STORE(__cached_dev)
38 bch_cached_dev_run(dc);
40 if (attr == &sysfs_cache_mode) {
41 - ssize_t v = bch_read_string_list(buf, bch_cache_modes + 1);
42 + v = bch_read_string_list(buf, bch_cache_modes + 1);