All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: xlpang@redhat.com
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Vivek Goyal <vgoyal@redhat.com>, Dave Young <dyoung@redhat.com>,
	Ingo Molnar <mingo@kernel.org>, Toshi Kani <toshi.kani@hpe.com>,
	Mimi Zohar <zohar@linux.vnet.ibm.com>,
	Minfei Huang <mnfhuang@gmail.com>,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [patch] kexec: potetially using uninitialized variable
Date: Fri, 11 Mar 2016 09:19:19 +0000	[thread overview]
Message-ID: <20160311091919.GD5273@mwanda> (raw)
In-Reply-To: <56E2875B.8010909@redhat.com>

On Fri, Mar 11, 2016 at 04:52:43PM +0800, Xunlei Pang wrote:
> Hi Dan,
> 
> On 2016/03/11 at 16:07, Dan Carpenter wrote:
> > At the end of the function we check if "ret" has a negative error code,
> > but it seems possible that it is uninitialized.
> >
> > Fixes: 12db5562e035 ('kexec: load and relocate purgatory at kernel load time')
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> >
> > diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c
> > index 503bc2d..63d1af3 100644
> > --- a/kernel/kexec_file.c
> > +++ b/kernel/kexec_file.c
> > @@ -795,7 +795,7 @@ out:
> >  
> >  static int kexec_apply_relocations(struct kimage *image)
> >  {
> > -	int i, ret;
> > +	int i, ret = 0;
> >  	struct purgatory_info *pi = &image->purgatory_info;
> >  	Elf_Shdr *sechdrs = pi->sechdrs;
> >  
> 
> Look further, there is a condition at the beginning of the for loop:
>  
> 
>         if (sechdrs[i].sh_type != SHT_RELA &&
>             sechdrs[i].sh_type != SHT_REL)
>             continue;
> 
> So, I think that's ok, but I don't konw if GCC is smart enough not to throw warnings.

Ah, right...

This wasn't a GCC warning.  GCC misses a lot of uninitialized variable
bugs so I'm doing this with Smatch.

Anyway, I'll patch this up in Smatch to not warn about this.

regards,
dan carpenter


WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: xlpang@redhat.com
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Vivek Goyal <vgoyal@redhat.com>, Dave Young <dyoung@redhat.com>,
	Ingo Molnar <mingo@kernel.org>, Toshi Kani <toshi.kani@hpe.com>,
	Mimi Zohar <zohar@linux.vnet.ibm.com>,
	Minfei Huang <mnfhuang@gmail.com>,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [patch] kexec: potetially using uninitialized variable
Date: Fri, 11 Mar 2016 12:19:19 +0300	[thread overview]
Message-ID: <20160311091919.GD5273@mwanda> (raw)
In-Reply-To: <56E2875B.8010909@redhat.com>

On Fri, Mar 11, 2016 at 04:52:43PM +0800, Xunlei Pang wrote:
> Hi Dan,
> 
> On 2016/03/11 at 16:07, Dan Carpenter wrote:
> > At the end of the function we check if "ret" has a negative error code,
> > but it seems possible that it is uninitialized.
> >
> > Fixes: 12db5562e035 ('kexec: load and relocate purgatory at kernel load time')
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> >
> > diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c
> > index 503bc2d..63d1af3 100644
> > --- a/kernel/kexec_file.c
> > +++ b/kernel/kexec_file.c
> > @@ -795,7 +795,7 @@ out:
> >  
> >  static int kexec_apply_relocations(struct kimage *image)
> >  {
> > -	int i, ret;
> > +	int i, ret = 0;
> >  	struct purgatory_info *pi = &image->purgatory_info;
> >  	Elf_Shdr *sechdrs = pi->sechdrs;
> >  
> 
> Look further, there is a condition at the beginning of the for loop:
>  
> 
>         if (sechdrs[i].sh_type != SHT_RELA &&
>             sechdrs[i].sh_type != SHT_REL)
>             continue;
> 
> So, I think that's ok, but I don't konw if GCC is smart enough not to throw warnings.

Ah, right...

This wasn't a GCC warning.  GCC misses a lot of uninitialized variable
bugs so I'm doing this with Smatch.

Anyway, I'll patch this up in Smatch to not warn about this.

regards,
dan carpenter

  reply	other threads:[~2016-03-11  9:19 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-11  8:07 [patch] kexec: potetially using uninitialized variable Dan Carpenter
2016-03-11  8:07 ` Dan Carpenter
2016-03-11  8:52 ` Xunlei Pang
2016-03-11  8:52   ` Xunlei Pang
2016-03-11  9:19   ` Dan Carpenter [this message]
2016-03-11  9:19     ` Dan Carpenter
2016-03-11  9:47     ` walter harms
2016-03-11  9:47       ` walter harms
2016-03-11 15:38       ` Minfei Huang
2016-03-11 15:38         ` Minfei Huang
2016-03-14 10:58         ` Dan Carpenter
2016-03-14 10:58           ` Dan Carpenter
2016-03-14 11:25           ` Minfei Huang
2016-03-14 11:25             ` Minfei Huang

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=20160311091919.GD5273@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=dyoung@redhat.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=mnfhuang@gmail.com \
    --cc=toshi.kani@hpe.com \
    --cc=vgoyal@redhat.com \
    --cc=xlpang@redhat.com \
    --cc=zohar@linux.vnet.ibm.com \
    /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.