From: Julien Grall <julien.grall@arm.com>
To: xen-devel@lists.xenproject.org
Cc: jgross@suse.com, Julien Grall <julien.grall@arm.com>,
Daniel De Graaf <dgdegra@tycho.nsa.gov>
Subject: [Xen-devel] [PATCH for-4.13] xen/xsm: flask: Check xmalloc_array() return in security_sid_to_context()
Date: Fri, 4 Oct 2019 17:56:46 +0100 [thread overview]
Message-ID: <20191004165646.14482-1-julien.grall@arm.com> (raw)
xmalloc_array() may return NULL if there are memory. Rather than trying
to deference it directly, we should check the return value first.
Coverity-ID: 1381852
Signed-off-by: Julien Grall <julien.grall@arm.com>
---
xen/xsm/flask/ss/services.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/xen/xsm/flask/ss/services.c b/xen/xsm/flask/ss/services.c
index b59928ea8a..42686535f2 100644
--- a/xen/xsm/flask/ss/services.c
+++ b/xen/xsm/flask/ss/services.c
@@ -775,6 +775,8 @@ int security_sid_to_context(u32 sid, char **scontext, u32 *scontext_len)
*scontext_len = strlen(initial_sid_to_string[sid]) + 1;
scontextp = xmalloc_array(char, *scontext_len);
+ if ( !scontextp )
+ return -ENOMEM;
strlcpy(scontextp, initial_sid_to_string[sid], *scontext_len);
*scontext = scontextp;
goto out;
--
2.11.0
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next reply other threads:[~2019-10-04 16:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-04 16:56 Julien Grall [this message]
2019-10-04 17:57 ` [Xen-devel] [PATCH for-4.13] xen/xsm: flask: Check xmalloc_array() return in security_sid_to_context() Daniel De Graaf
2019-10-07 6:46 ` Jürgen Groß
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=20191004165646.14482-1-julien.grall@arm.com \
--to=julien.grall@arm.com \
--cc=dgdegra@tycho.nsa.gov \
--cc=jgross@suse.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.