From: Zdenek Kabelac Date: Mon, 15 Oct 2018 13:02:09 +0000 (+0200) Subject: cov: add check for positive value X-Git-Tag: v2_03_01~32 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=eb566e034fecd27ced0dc1133e19ced2636b3714;p=lvm2.git 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. --- 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;