]> xenbits.xensource.com Git - people/dariof/xen.git/commitdiff
xen/arm: optee: fix compilation with GCC 4.8
authorVolodymyr Babchuk <Volodymyr_Babchuk@epam.com>
Thu, 20 Jun 2019 15:50:21 +0000 (15:50 +0000)
committerJulien Grall <julien.grall@arm.com>
Fri, 21 Jun 2019 09:29:58 +0000 (10:29 +0100)
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@xilinx.com>
Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
Acked-by: Julien Grall <julien.grall@arm.com>
xen/arch/arm/tee/optee.c

index 28d34360fc999efd1a6547a2d9ca90f11720f856..61029855d44e4ebf2e7309ef7f2061886228c562 100644 (file)
@@ -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;