Skip to content

Commit a6c5e7a

Browse files
taslesongregkh
authored andcommitted
bcache: Correct return value for sysfs attach errors
commit 77fa100f27475d08a569b9d51c17722130f089e7 upstream. If you encounter any errors in bch_cached_dev_attach it will return a negative error code. The variable 'v' which stores the result is unsigned, thus user space sees a very large value returned for bytes written which can cause incorrect user space behavior. Utilize 1 signed variable to use throughout the function to preserve error return capability. Signed-off-by: Tony Asleson <tasleson@redhat.com> Acked-by: Coly Li <colyli@suse.de> Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent d9c6a28 commit a6c5e7a

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

drivers/md/bcache/sysfs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ STORE(__cached_dev)
191191
{
192192
struct cached_dev *dc = container_of(kobj, struct cached_dev,
193193
disk.kobj);
194-
unsigned v = size;
194+
ssize_t v = size;
195195
struct cache_set *c;
196196
struct kobj_uevent_env *env;
197197

@@ -226,7 +226,7 @@ STORE(__cached_dev)
226226
bch_cached_dev_run(dc);
227227

228228
if (attr == &sysfs_cache_mode) {
229-
ssize_t v = bch_read_string_list(buf, bch_cache_modes + 1);
229+
v = bch_read_string_list(buf, bch_cache_modes + 1);
230230

231231
if (v < 0)
232232
return v;

0 commit comments

Comments
 (0)