All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jan Beulich" <JBeulich@suse.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Ian Murray <murrayie@yahoo.co.uk>, Keir Fraser <keir@xen.org>,
	Ian Campbell <ian.campbell@citrix.com>,
	Don Slutz <dslutz@verizon.com>,
	xen-devel@lists.xen.org
Subject: Re: [PATCH 1/1] hvm.c: Prevent gcc uninitialised var warning
Date: Wed, 25 Mar 2015 15:48:12 +0000	[thread overview]
Message-ID: <5512E6CC020000780006D883@mail.emea.novell.com> (raw)
In-Reply-To: <5512CE05.6010105@citrix.com>

>>> On 25.03.15 at 16:02, <andrew.cooper3@citrix.com> wrote:
> On 23/03/15 15:01, Don Slutz wrote:
>> gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3 reports:
>> ----------------------------------------------------------------------
>> hvm.c: In function `hvm_create_ioreq_server':
>> hvm.c:487:18: error: `bufioreq_pfn' may be used uninitialised in this 
> function
>> [-Werror=uninitialized]
>> hvm.c:718:30: note: `bufioreq_pfn' was declared here
>> ----------------------------------------------------------------------
>>
>> My code analysis says that gcc is wrong, but initilize the variable
>> to prevent the gcc warning.
>>
>> Reported-by: Ian Murray <murrayie@yahoo.co.uk>
>> Signed-off-by: Don Slutz <dslutz@verizon.com>
> 
> GCC is correct and there is path through this function where
> bufioreq_pfn is used while uninitialised (non-debug build, is_default =
> 1, handle_bufioreq = 0).

I'm not seeing it: When is_default is set, bufioreq_pfn gets
initialized in the first if()'s body.

> As an aside, the compiler is in a very easy position to spot this.  The
> error means that GCC has positively identified a basic block which does
> use bufioreq_pfn before it has been initialised.
> 
> I observe that the patch has been committed, but it merely hides the
> problem and doesn't fix it; hvm_free_ioreq_gmfn(d, bufioreq_pfn) will
> still clobber arbitrary memory.

I committed the patch based on me not being able to find a path
where the variable would actually be used uninitialized (and it is
known that various gcc versions have varying levels of problems
with correctly identifying such issues). If indeed there is a path
that I'm not seeing, then I'd indeed favor reverting and putting
in a proper, backportable fix.

Jan

  reply	other threads:[~2015-03-25 15:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-23 14:01 [PATCH 1/1] hvm.c: Prevent gcc uninitialised var warning Don Slutz
2015-03-25 15:02 ` Andrew Cooper
2015-03-25 15:48   ` Jan Beulich [this message]
2015-03-25 20:03     ` Don Slutz
2015-03-26  7:48       ` Jan Beulich
2015-03-26 11:15         ` Ian Murray

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=5512E6CC020000780006D883@mail.emea.novell.com \
    --to=jbeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=dslutz@verizon.com \
    --cc=ian.campbell@citrix.com \
    --cc=keir@xen.org \
    --cc=murrayie@yahoo.co.uk \
    --cc=xen-devel@lists.xen.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.