[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen stable-4.7] xen/livepatch: Use zeroed memory allocations for arrays



commit ece330ae94e8bcb6d02e7727101a6769daf45cbf
Author:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
AuthorDate: Mon Aug 28 13:00:59 2017 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Mon Aug 28 13:00:59 2017 +0200

    xen/livepatch: Use zeroed memory allocations for arrays
    
    Each of these arrays is sparse.  Use zeroed allocations to cause 
uninitialised
    array elements to contain deterministic values, most importantly for the
    embedded pointers.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
    Tested-by: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx> [x86 and arm32]
    Reviewed-by: Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>
    master commit: bd53b85156aaf0330181ab9b82d9a6c52fb30f8c
    master date: 2017-06-23 15:00:37 +0100
---
 xen/common/livepatch.c     | 4 ++--
 xen/common/livepatch_elf.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/xen/common/livepatch.c b/xen/common/livepatch.c
index c9a7698..dc6778a 100644
--- a/xen/common/livepatch.c
+++ b/xen/common/livepatch.c
@@ -707,8 +707,8 @@ static int build_symbol_table(struct payload *payload,
         }
     }
 
-    symtab = xmalloc_array(struct livepatch_symbol, nsyms);
-    strtab = xmalloc_array(char, strtab_len);
+    symtab = xzalloc_array(struct livepatch_symbol, nsyms);
+    strtab = xzalloc_array(char, strtab_len);
 
     if ( !strtab || !symtab )
     {
diff --git a/xen/common/livepatch_elf.c b/xen/common/livepatch_elf.c
index 789e8fc..e7017fa 100644
--- a/xen/common/livepatch_elf.c
+++ b/xen/common/livepatch_elf.c
@@ -52,7 +52,7 @@ static int elf_resolve_sections(struct livepatch_elf *elf, 
const void *data)
     int rc;
 
     /* livepatch_elf_load sanity checked e_shnum. */
-    sec = xmalloc_array(struct livepatch_elf_sec, elf->hdr->e_shnum);
+    sec = xzalloc_array(struct livepatch_elf_sec, elf->hdr->e_shnum);
     if ( !sec )
     {
         dprintk(XENLOG_ERR, LIVEPATCH"%s: Could not allocate memory for 
section table!\n",
@@ -221,7 +221,7 @@ static int elf_get_sym(struct livepatch_elf *elf, const 
void *data)
     /* No need to check values as elf_resolve_sections did it. */
     nsym = symtab_sec->sec->sh_size / symtab_sec->sec->sh_entsize;
 
-    sym = xmalloc_array(struct livepatch_elf_sym, nsym);
+    sym = xzalloc_array(struct livepatch_elf_sym, nsym);
     if ( !sym )
     {
         dprintk(XENLOG_ERR, LIVEPATCH "%s: Could not allocate memory for 
symbols\n",
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.7

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.