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

[Xen-changelog] [xen master] xen/arm: optee: fix compilation with GCC 4.8



commit 7d1460c991ac45cccbf9ba3d8aa137029c2bf312
Author:     Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
AuthorDate: Thu Jun 20 15:50:21 2019 +0000
Commit:     Julien Grall <julien.grall@xxxxxxx>
CommitDate: Fri Jun 21 10:29:58 2019 +0100

    xen/arm: optee: fix compilation with GCC 4.8
    
    GCC 4.8 is unable to see that variables guest_pg, guest_data and
    xen_data will be always initialized before access, so we need to
    initialize them earlier.
    
    Suggested-by: Stefano Stabellini <stefanos@xxxxxxxxxx>
    Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@xxxxxxxx>
    Acked-by: Julien Grall <julien.grall@xxxxxxx>
---
 xen/arch/arm/tee/optee.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/xen/arch/arm/tee/optee.c b/xen/arch/arm/tee/optee.c
index 28d34360fc..61029855d4 100644
--- a/xen/arch/arm/tee/optee.c
+++ b/xen/arch/arm/tee/optee.c
@@ -707,6 +707,19 @@ static int translate_noncontig(struct optee_domain *ctx,
     gfn = gaddr_to_gfn(param->u.tmem.buf_ptr &
                        ~(OPTEE_MSG_NONCONTIG_PAGE_SIZE - 1));
 
+    /*
+     * We are initializing guest_pg, guest_data and xen_data with NULL
+     * to make GCC 4.8 happy, as it can't infer that those variables
+     * will be initialized with correct values in the loop below.
+     *
+     * This silences old GCC, but can lead to NULL dereference, in
+     * case of programmer's mistake. To minimize chance of this, we
+     * are initializing those variables there, instead of doing this
+     * at beginning of the function.
+     */
+    guest_pg = NULL;
+    xen_data = NULL;
+    guest_data = NULL;
     while ( pg_count )
     {
         struct page_info *page;
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
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®.