xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
To: Stefano Stabellini <sstabellini@kernel.org>,
	Julien Grall <julien.grall@arm.com>
Cc: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
	Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>,
	Stefano Stabellini <stefanos@xilinx.com>
Subject: [Xen-devel] [PATCH] xen/arm: optee: fix compilation with GCC 4.8
Date: Thu, 20 Jun 2019 15:50:21 +0000	[thread overview]
Message-ID: <20190620154952.31286-1-volodymyr_babchuk@epam.com> (raw)


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>
---
 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 14381d6b2d..5526875e6f 100644
--- a/xen/arch/arm/tee/optee.c
+++ b/xen/arch/arm/tee/optee.c
@@ -717,6 +717,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;
-- 
2.21.0

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

             reply	other threads:[~2019-06-20 15:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-20 15:50 Volodymyr Babchuk [this message]
2019-06-21  0:28 ` [Xen-devel] [PATCH] xen/arm: optee: fix compilation with GCC 4.8 Stefano Stabellini
2019-06-21  9:33   ` Julien Grall

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=20190620154952.31286-1-volodymyr_babchuk@epam.com \
    --to=volodymyr_babchuk@epam.com \
    --cc=julien.grall@arm.com \
    --cc=sstabellini@kernel.org \
    --cc=stefanos@xilinx.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).