Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

bcache: not use hard coded memset size in bch_cache_accounting_clear()

In stats.c:bch_cache_accounting_clear(), a hard coded number '7' is
used in memset(). It is because in struct cache_stats, there are 7
atomic_t type members. This is not good when new members added into
struct stats, the hard coded number will only clear part of memory.

This patch replaces 'sizeof(unsigned long) * 7' by more generic
'sizeof(struct cache_stats))', to avoid potential error if new
member added into struct cache_stats.

Signed-off-by: Coly Li <colyli@suse.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Coly Li and committed by
Jens Axboe
83ff9318 9951379b

+1 -1
+1 -1
drivers/md/bcache/stats.c
··· 111 111 { 112 112 memset(&acc->total.cache_hits, 113 113 0, 114 - sizeof(unsigned long) * 7); 114 + sizeof(struct cache_stats)); 115 115 } 116 116 117 117 void bch_cache_accounting_destroy(struct cache_accounting *acc)