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 <nmant...@amazon.de> Reviewed-by: Thomas Friebel <frieb...@amazon.de> Reviewed-by: Julien Grall <jgr...@amazon.co.uk> --- tools/xenstore/xenstored_core.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_core.c --- a/tools/xenstore/xenstored_core.c +++ b/tools/xenstore/xenstored_core.c @@ -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); -- 2.17.1 Amazon Development Center Germany GmbH Krausenstr. 38 10117 Berlin Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B Sitz: Berlin Ust-ID: DE 289 237 879