From eb566e034fecd27ced0dc1133e19ced2636b3714 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Mon, 15 Oct 2018 15:02:09 +0200 Subject: [PATCH] cov: add check for positive value As pgsize parameter for _init_free_list() can't be negative, report problem in case for any reason we would get negative number. --- lib/device/bcache.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/device/bcache.c b/lib/device/bcache.c index 43ca63e24..8b2c7f880 100644 --- a/lib/device/bcache.c +++ b/lib/device/bcache.c @@ -881,6 +881,11 @@ struct bcache *bcache_create(sector_t block_sectors, unsigned nr_cache_blocks, unsigned max_io = engine->max_io(engine); long pgsize = sysconf(_SC_PAGESIZE); + if (pgsize < 0) { + log_warn("WARNING: _SC_PAGESIZE returns negative value."); + return NULL; + } + if (!nr_cache_blocks) { log_warn("bcache must have at least one cache block"); return NULL; -- 2.43.5