From: Juergen Gross <jgross@suse.com>
To: xen-devel@lists.xenproject.org
Cc: Juergen Gross <jgross@suse.com>,
wei.liu2@citrix.com, ian.jackson@eu.citrix.com
Subject: [PATCH 2/2] xenstore: add missing checks for allocation failure
Date: Mon, 20 Mar 2017 09:00:21 +0100 [thread overview]
Message-ID: <20170320080021.12720-3-jgross@suse.com> (raw)
In-Reply-To: <20170320080021.12720-1-jgross@suse.com>
Add a missing allocation failure checks.
Signed-off-by: Juergen Gross <jgross@suse.com>
---
tools/xenstore/xenstored_core.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_core.c
index ed80345..fe11ff2 100644
--- a/tools/xenstore/xenstored_core.c
+++ b/tools/xenstore/xenstored_core.c
@@ -946,6 +946,8 @@ static struct node *construct_node(struct connection *conn, const void *ctx,
base = basename(name);
baselen = strlen(base) + 1;
children = talloc_array(ctx, char, parent->childlen + baselen);
+ if (!children)
+ goto nomem;
memcpy(children, parent->children, parent->childlen);
memcpy(children + parent->childlen, base, baselen);
parent->children = children;
@@ -953,13 +955,19 @@ static struct node *construct_node(struct connection *conn, const void *ctx,
/* Allocate node */
node = talloc(ctx, struct node);
+ if (!node)
+ goto nomem;
node->tdb = tdb_context(conn);
node->name = talloc_strdup(node, name);
+ if (!node->name)
+ goto nomem;
/* Inherit permissions, except unprivileged domains own what they create */
node->num_perms = parent->num_perms;
node->perms = talloc_memdup(node, parent->perms,
node->num_perms * sizeof(node->perms[0]));
+ if (!node->perms)
+ goto nomem;
if (domain_is_unprivileged(conn))
node->perms[0].id = conn->id;
@@ -969,6 +977,10 @@ static struct node *construct_node(struct connection *conn, const void *ctx,
node->parent = parent;
domain_entry_inc(conn, node);
return node;
+
+nomem:
+ errno = ENOMEM;
+ return NULL;
}
static int destroy_node(void *_node)
--
2.10.2
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-03-20 8:00 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-20 8:00 [PATCH 0/2] xensore: fixing two bugs Juergen Gross
2017-03-20 8:00 ` [PATCH 1/2] xenstore: set correct error code when violating quota Juergen Gross
2017-03-21 17:14 ` Wei Liu
2017-03-21 17:16 ` Wei Liu
2017-03-21 17:21 ` Juergen Gross
2017-03-21 17:45 ` Wei Liu
2017-03-20 8:00 ` Juergen Gross [this message]
2017-03-21 17:17 ` [PATCH 2/2] xenstore: add missing checks for allocation failure Wei Liu
2017-04-03 13:54 ` [PATCH 0/2] xensore: fixing two bugs Ian Jackson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170320080021.12720-3-jgross@suse.com \
--to=jgross@suse.com \
--cc=ian.jackson@eu.citrix.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).