From: Michael Kurth Date: Fri, 26 Feb 2021 14:41:42 +0000 (+0100) Subject: xenstore: add missing NULL check X-Git-Tag: 4.15.0-rc3~29 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=ff3e7e76813a7958e583e6d7e9090ff9b6df1ecd;p=people%2Ftklengyel%2Fxen.git xenstore: add missing NULL check In case of allocation error, we should not dereference the obtained NULL pointer. This bug was discovered and resolved using Coverity Static Analysis Security Testing (SAST) by Synopsys, Inc. Signed-off-by: Michael Kurth 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 8febd09f55..8033c1e0eb 100644 --- a/tools/xenstore/xenstored_core.c +++ b/tools/xenstore/xenstored_core.c @@ -504,6 +504,11 @@ int write_node_raw(struct connection *conn, TDB_DATA *key, struct node *node, } data.dptr = talloc_size(node, data.dsize); + if (!data.dptr) { + errno = ENOMEM; + return errno; + } + hdr = (void *)data.dptr; hdr->generation = node->generation; hdr->num_perms = node->perms.num;