]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
mbcache: make sure c_entry_count is not decremented past zero
authorJiang Biao <jiang.biao2@zte.com.cn>
Wed, 10 Jan 2018 04:57:52 +0000 (23:57 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 10 Jan 2018 04:57:52 +0000 (23:57 -0500)
Signed-off-by: Jiang Biao <jiang.biao2@zte.com.cn>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
CC: Eric Biggers <ebiggers@google.com>
CC: Andrew Morton <akpm@linux-foundation.org>
CC: Jan Kara <jack@suse.cz>
fs/mbcache.c

index 49c5b25bfa8cb2f92a34fde352ee4541b4581c9c..bf41e2e72c1883b7fba884a8f7006ecc50bcf768 100644 (file)
@@ -239,7 +239,9 @@ void mb_cache_entry_delete(struct mb_cache *cache, u32 key, u64 value)
                        spin_lock(&cache->c_list_lock);
                        if (!list_empty(&entry->e_list)) {
                                list_del_init(&entry->e_list);
-                               cache->c_entry_count--;
+                               if (!WARN_ONCE(cache->c_entry_count == 0,
+               "mbcache: attempt to decrement c_entry_count past zero"))
+                                       cache->c_entry_count--;
                                atomic_dec(&entry->e_refcnt);
                        }
                        spin_unlock(&cache->c_list_lock);