]> sourceware.org Git - lvm2.git/commitdiff
cov: add check for positive value
authorZdenek Kabelac <zkabelac@redhat.com>
Mon, 15 Oct 2018 13:02:09 +0000 (15:02 +0200)
committerZdenek Kabelac <zkabelac@redhat.com>
Mon, 15 Oct 2018 15:49:44 +0000 (17:49 +0200)
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

index 43ca63e2488cbd6c26e893052a8e2c0880a9e840..8b2c7f88097cb4039e6b116319f6b8251758673f 100644 (file)
@@ -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;
This page took 0.039797 seconds and 5 git commands to generate.