]> xenbits.xensource.com Git - people/larsk/xen.git/commitdiff
xen/xsm: flask: Check xmalloc_array() return in security_sid_to_context()
authorJulien Grall <julien.grall@arm.com>
Fri, 4 Oct 2019 16:53:26 +0000 (17:53 +0100)
committerJulien Grall <julien.grall@arm.com>
Mon, 7 Oct 2019 09:09:34 +0000 (10:09 +0100)
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>
Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Release-acked-by: Juergen Gross <jgross@suse.com>
xen/xsm/flask/ss/services.c

index b59928ea8a98e90d8e1b2f7b9ee11b7d866f911d..42686535f2c4d9e509b353eef7c6b168742bb695 100644 (file)
@@ -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;