kexec.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Dave Young <dyoung@redhat.com>
To: Simon Horman <horms@verge.net.au>
Cc: panand@redhat.com, Madhavan Srinivasan <maddy@linux.vnet.ibm.com>,
	kexec@lists.infradead.org
Subject: Re: [PATCH v2] kexec/fs2dt: Check for NULL pointer in dt_copy_old_root_param()
Date: Thu, 29 Sep 2016 16:29:11 +0800	[thread overview]
Message-ID: <20160929082911.GA13033@dhcp-128-65.nay.redhat.com> (raw)
In-Reply-To: <20160929082020.GH14497@verge.net.au>

On 09/29/16 at 10:20am, Simon Horman wrote:
> [CC Dave Young]
> 
> On Thu, Sep 29, 2016 at 01:29:13PM +0530, Madhavan Srinivasan wrote:
> > In dt_copy_old_root_param(), FILE * returned
> > from fopen is not checked for NULL pointer
> > before passinig to fclose(). This could trigger
> > a segfault. Patch to fix the same.
> > 
> > Reviewed-by: Dave Young <dyoung@redhat.com>
> 
> Probably Dave's tag should be dropped as that was for a somewhat
> different (though equally trivial) approach.

Simion, I think I'm fine with any of them. 

> 
> > Signed-off-by: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
> > ---
> > Changelog v1:
> >  - Moved the check right after fopen
> > 
> >  kexec/fs2dt.c | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/kexec/fs2dt.c b/kexec/fs2dt.c
> > index 6ed2399759cf..5ba3ec0fa65c 100644
> > --- a/kexec/fs2dt.c
> > +++ b/kexec/fs2dt.c
> > @@ -524,6 +524,9 @@ static void dt_copy_old_root_param(void)
> >  	strcpy(filename, pathname);
> >  	strcat(filename, "bootargs");
> >  	fp = fopen(filename, "r");
> > +	if (!fp)
> > +		return;
> > +
> 
> With the (!fp) conditional above the (fp) conditional below can be removed.
> 
> >  	if (fp) {
> >  		if (getline(&last_cmdline, &len, fp) == -1)
> >  			die("unable to read %s\n", filename);
> > -- 
> > 2.7.4
> > 

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

  reply	other threads:[~2016-09-29  8:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-29  7:59 [PATCH v2] kexec/fs2dt: Check for NULL pointer in dt_copy_old_root_param() Madhavan Srinivasan
2016-09-29  8:20 ` Simon Horman
2016-09-29  8:29   ` Dave Young [this message]
2016-09-29  8:24 ` Pratyush Anand

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=20160929082911.GA13033@dhcp-128-65.nay.redhat.com \
    --to=dyoung@redhat.com \
    --cc=horms@verge.net.au \
    --cc=kexec@lists.infradead.org \
    --cc=maddy@linux.vnet.ibm.com \
    --cc=panand@redhat.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 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).