Message ID | 20210226144144.9252-9-nmanthey@amazon.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Code analysis fixes | expand |
On 26.02.21 15:41, Norbert Manthey wrote: > From: Michael Kurth <mku@amazon.com> > > 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 <mku@amazon.com> > 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> Juergen
Norbert Manthey writes ("[PATCH XENSTORE v1 08/10] xenstore: add missing NULL check"): > From: Michael Kurth <mku@amazon.com> > > 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 <mku@amazon.com> > Signed-off-by: Norbert Manthey <nmanthey@amazon.de> > Reviewed-by: Thomas Friebel <friebelt@amazon.de> > Reviewed-by: Julien Grall <jgrall@amazon.co.uk> Release-Acked-by: Ian Jackson <iwj@xenproject.org>
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 @@ -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;