From: Norbert Manthey Date: Fri, 26 Feb 2021 14:41:35 +0000 (+0100) Subject: xenstore: add missing NULL check X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=0bdaa8b035ec9fbdfd4e4f25f0577016c94b7a50;p=people%2Fsstabellini%2Fxen-unstable.git%2F.git xenstore: add missing NULL check 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 Reviewed-by: Thomas Friebel Reviewed-by: Julien Grall Reviewed-by: Juergen Gross Release-Acked-by: Ian Jackson --- diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_core.c index 0fea598352..3803aef081 100644 --- 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);