1 mbcache: make sure c_entry_count is not decremented past zero
3 From: Jiang Biao <jiang.biao2@zte.com.cn>
5 Signed-off-by: Jiang Biao <jiang.biao2@zte.com.cn>
6 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
7 CC: Eric Biggers <ebiggers@google.com>
8 CC: Andrew Morton <akpm@linux-foundation.org>
9 CC: Jan Kara <jack@suse.cz>
12 1 file changed, 3 insertions(+), 1 deletion(-)
14 diff --git a/fs/mbcache.c b/fs/mbcache.c
15 index 0851af5c1c3d..f2f15b747bed 100644
18 @@ -239,7 +239,9 @@ void mb_cache_entry_delete(struct mb_cache *cache, u32 key, u64 value)
19 spin_lock(&cache->c_list_lock);
20 if (!list_empty(&entry->e_list)) {
21 list_del_init(&entry->e_list);
22 - cache->c_entry_count--;
23 + if (!WARN_ONCE(cache->c_entry_count == 0,
24 + "mbcache: attempt to decrement c_entry_count past zero"))
25 + cache->c_entry_count--;
26 atomic_dec(&entry->e_refcnt);
28 spin_unlock(&cache->c_list_lock);