]> xenbits.xensource.com Git - people/tklengyel/xen.git/commitdiff
xenstore: add missing NULL check
authorNorbert Manthey <nmanthey@amazon.de>
Fri, 26 Feb 2021 14:41:35 +0000 (15:41 +0100)
committerJulien Grall <jgrall@amazon.com>
Wed, 3 Mar 2021 18:11:11 +0000 (18:11 +0000)
In case of allocation error, we should not dereference the obtained
NULL pointer. Hence, fail early.

This bug was discovered and resolved using Coverity Static Analysis
Security Testing (SAST) by Synopsys, Inc.

Signed-off-by: Norbert Manthey <nmanthey@amazon.de>
Reviewed-by: Thomas Friebel <friebelt@amazon.de>
Reviewed-by: Julien Grall <jgrall@amazon.co.uk>
Reviewed-by: Juergen Gross <jgross@suse.com>
Release-Acked-by: Ian Jackson <iwj@xenproject.org>
tools/xenstore/xenstored_core.c

index 0fea598352645ba4f5f03efda3e29b579a7ba03f..3803aef081ba5040dfafc7f641ccfca675086d68 100644 (file)
@@ -1818,6 +1818,10 @@ static int check_store_(const char *name, struct hashtable *reachable)
 
                struct hashtable * children =
                        create_hashtable(16, hash_from_key_fn, keys_equal_fn);
+               if (!children) {
+                       log("check_store create table: ENOMEM");
+                       return ENOMEM;
+               }
 
                if (!remember_string(reachable, name)) {
                        hashtable_destroy(children, 0);