linux/drivers/md/bcache
Coly Li 46451874c7 bcache: fix error setting writeback_rate through sysfs interface
Commit ea8c5356d3 ("bcache: set max writeback rate when I/O request
is idle") changes struct bch_ratelimit member rate from uint32_t to
atomic_long_t and uses atomic_long_set() in drivers/md/bcache/sysfs.c
to set new writeback rate, after the input is converted from memory
buf to long int by sysfs_strtoul_clamp().

The above change has a problem because there is an implicit return
inside sysfs_strtoul_clamp() so the following atomic_long_set()
won't be called. This error is detected by 0day system with following
snipped smatch warnings:

drivers/md/bcache/sysfs.c:271 __cached_dev_store() error: uninitialized
symbol 'v'.
270  sysfs_strtoul_clamp(writeback_rate, v, 1, INT_MAX);
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@271 atomic_long_set(&dc->writeback_rate.rate, v);

This patch fixes the above error by using strtoul_safe_clamp() to
convert the input buffer into a long int type result.

Fixes: ea8c5356d3 ("bcache: set max writeback rate when I/O request is idle")
Cc: Kai Krakow <kai@kaishome.de>
Cc: Stefan Priebe <s.priebe@profihost.ag>
Signed-off-by: Coly Li <colyli@suse.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2018-08-10 12:18:47 -06:00
..
alloc.c bcache: add wait_for_kthread_stop() in bch_allocator_thread() 2018-05-03 08:35:13 -06:00
bcache.h bcache: set max writeback rate when I/O request is idle 2018-08-09 08:21:15 -06:00
bset.c bcache: add code comments for bset.c 2018-08-09 08:21:12 -06:00
bset.h bcache: convert to bioset_init()/mempool_init() 2018-05-30 15:33:32 -06:00
btree.c bcache: avoid unncessary cache prefetch bch_btree_node_get() 2018-08-09 08:21:05 -06:00
btree.h bcache: trivial - remove tailing backslash in macro BTREE_FLAG 2018-08-09 08:21:19 -06:00
closure.c bcache: do not check return value of debugfs_create_dir() 2018-08-09 08:21:01 -06:00
closure.h bcache: do not check return value of debugfs_create_dir() 2018-08-09 08:21:01 -06:00
debug.c bcache: do not check return value of debugfs_create_dir() 2018-08-09 08:21:01 -06:00
debug.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
extents.c docs: Fix some broken references 2018-06-15 18:10:01 -03:00
extents.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
io.c bcache: convert to bioset_init()/mempool_init() 2018-05-30 15:33:32 -06:00
journal.c bcache: free heap cache_set->flush_btree in bch_journal_free 2018-07-27 09:15:46 -06:00
journal.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
Kconfig docs: Fix some broken references 2018-06-15 18:10:01 -03:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
movinggc.c block: move bio_alloc_pages() to bcache 2018-01-06 09:18:00 -07:00
request.c bcache: set max writeback rate when I/O request is idle 2018-08-09 08:21:15 -06:00
request.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
stats.c md: Convert timers to use timer_setup() 2017-11-14 20:11:57 -07:00
stats.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
super.c bcache: set max writeback rate when I/O request is idle 2018-08-09 08:21:15 -06:00
sysfs.c bcache: fix error setting writeback_rate through sysfs interface 2018-08-10 12:18:47 -06:00
sysfs.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
trace.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
util.c bcache: set max writeback rate when I/O request is idle 2018-08-09 08:21:15 -06:00
util.h bcache: set max writeback rate when I/O request is idle 2018-08-09 08:21:15 -06:00
writeback.c bcache: set max writeback rate when I/O request is idle 2018-08-09 08:21:15 -06:00
writeback.h bcache: simplify the calculation of the total amount of flash dirty data 2018-07-27 09:15:46 -06:00