]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.9.52/bcache-correct-return-value-for-sysfs-attach-errors.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.9.52 / bcache-correct-return-value-for-sysfs-attach-errors.patch
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
5
6 From: Tony Asleson <tasleson@redhat.com>
7
8 commit 77fa100f27475d08a569b9d51c17722130f089e7 upstream.
9
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
15 capability.
16
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>
21
22 ---
23 drivers/md/bcache/sysfs.c | 4 ++--
24 1 file changed, 2 insertions(+), 2 deletions(-)
25
26 --- a/drivers/md/bcache/sysfs.c
27 +++ b/drivers/md/bcache/sysfs.c
28 @@ -191,7 +191,7 @@ STORE(__cached_dev)
29 {
30 struct cached_dev *dc = container_of(kobj, struct cached_dev,
31 disk.kobj);
32 - unsigned v = size;
33 + ssize_t v = size;
34 struct cache_set *c;
35 struct kobj_uevent_env *env;
36
37 @@ -226,7 +226,7 @@ STORE(__cached_dev)
38 bch_cached_dev_run(dc);
39
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);
43
44 if (v < 0)
45 return v;