]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: check blkid_get_cache() return value [coverity scan]
authorKarel Zak <kzak@redhat.com>
Fri, 10 Dec 2021 15:22:07 +0000 (16:22 +0100)
committerKarel Zak <kzak@redhat.com>
Fri, 10 Dec 2021 15:22:07 +0000 (16:22 +0100)
CID 374488:  Error handling issues  (CHECKED_RETURN)
Calling "blkid_get_cache" without checking return value (as is done elsewhere 4 out of 5 times).

It's probably unnecessary as we check the cache pointer later, but let's
make it more robust for static analyzers.

Signed-off-by: Karel Zak <kzak@redhat.com>
libblkid/src/evaluate.c

index 710eac95663487c67e66c06772fbf494c10060f9..8157a7cca63e6386c4b7efab414435a0f1be1894 100644 (file)
@@ -200,8 +200,10 @@ static char *evaluate_by_scan(const char *token, const char *value,
 
        if (!c) {
                char *cachefile = blkid_get_cache_filename(conf);
-               blkid_get_cache(&c, cachefile);
+               int rc = blkid_get_cache(&c, cachefile);
                free(cachefile);
+               if (rc < 0)
+                       return NULL;
        }
        if (!c)
                return NULL;