]> sourceware.org Git - lvm2.git/commitdiff
bcache: fix incorrect pointer check
authorZdenek Kabelac <zkabelac@redhat.com>
Tue, 9 Mar 2021 18:35:53 +0000 (19:35 +0100)
committerZdenek Kabelac <zkabelac@redhat.com>
Tue, 9 Mar 2021 23:59:05 +0000 (00:59 +0100)
With commit b44db5d1a7ecc2e8e3cef0852c4397b64ddf0a09
needs to check allocated pointer for failed malloc().

Existing check was actually no checking anything so failing
malloc here would result in segfault (although with very
low chance to ever happen).

lib/device/bcache.c

index a3803befb44a885dcb7d9c9ed90db07d3214fa76..a5f2a5a86afb23e780e03b895389efff6ccfaff0 100644 (file)
@@ -74,7 +74,7 @@ static struct cb_set *_cb_set_create(unsigned nr)
        unsigned i;
        struct cb_set *cbs = malloc(sizeof(*cbs) + nr * sizeof(*cbs->vec));
 
-       if (!cbs->vec)
+       if (!cbs)
                return NULL;
 
        dm_list_init(&cbs->free);
This page took 0.040052 seconds and 5 git commands to generate.