All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kent Yoder <key@linux.vnet.ibm.com>
To: Jesper Juhl <jj@chaosbits.net>
Cc: linux-kernel@vger.kernel.org, tpmdd-devel@lists.sourceforge.net,
	Sirrix AG <tpmdd@sirrix.com>,
	Marcel Selhorst <tpmdd@selhorst.net>,
	Rajiv Andrade <mail@srajiv.net>,
	Seiji Munetoh <munetoh@jp.ibm.com>,
	Stefan Berger <stefanb@us.ibm.com>,
	Reiner Sailer <sailer@watson.ibm.com>,
	Kylene Hall <kjhall@us.ibm.com>
Subject: Re: [PATCH] tpm: Do not dereference NULL pointer if acpi_os_map_memory() fails.
Date: Wed, 15 Aug 2012 15:15:27 -0500	[thread overview]
Message-ID: <20120815201527.GC27618@linux.vnet.ibm.com> (raw)
In-Reply-To: <20120808180750.GA24016@linux.vnet.ibm.com>

Hi Jesper,

> > Unfortunately we just get NULL back, so we can't really tell the user
> > exactely what went wrong, but we can at least avoid crashing and
> > return an error (-EIO seemed more generic and more suitable here than
> > -ENOMEM or something else, so I picked that).
> 
> Thanks Jesper. I'd made some updates to tpm_bios.c recently but this
> should still apply. I'll let you know if not.

  Of course I'm wrong here, this code moved over into tpm_acpi.c. If you
can resubmit on top of my staging tree, I will apply it there.

git://github.com/shpedoikal/linux.git v3.6-rc1-tpmdd-staging

> > Signed-off-by: Jesper Juhl <jj@chaosbits.net>
> > ---
> >  drivers/char/tpm/tpm_bios.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> > 
> >   Compile tested only.
> > 
> > diff --git a/drivers/char/tpm/tpm_bios.c b/drivers/char/tpm/tpm_bios.c
> > index 0636520..0c5c274 100644
> > --- a/drivers/char/tpm/tpm_bios.c
> > +++ b/drivers/char/tpm/tpm_bios.c
> > @@ -410,6 +410,11 @@ static int read_log(struct tpm_bios_log *log)
> >  	log->bios_event_log_end = log->bios_event_log + len;
> > 
> >  	virt = acpi_os_map_memory(start, len);
> > +	if (!virt) {

  Also please add kfree(log->bios_event_log); in this error path.

Thanks,
Kent

> > +		printk("%s: ERROR - Unable to map memory\n",
> > +			__func__);
> > +		return -EIO;
> > +	}
> > 
> >  	memcpy(log->bios_event_log, virt, len);
> > 
> > -- 
> > 1.7.11.4
> > 
> > 
> > -- 
> > Jesper Juhl <jj@chaosbits.net>       http://www.chaosbits.net/
> > Don't top-post http://www.catb.org/jargon/html/T/top-post.html
> > Plain text mails only, please.
> > 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 


  reply	other threads:[~2012-08-15 20:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-07 20:50 [PATCH] tpm: Do not dereference NULL pointer if acpi_os_map_memory() fails Jesper Juhl
2012-08-08 18:07 ` Kent Yoder
2012-08-15 20:15   ` Kent Yoder [this message]
2012-08-15 22:02     ` Jesper Juhl
2012-08-15 22:16       ` Jesper Juhl
2012-08-16 15:45         ` Kent Yoder

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=20120815201527.GC27618@linux.vnet.ibm.com \
    --to=key@linux.vnet.ibm.com \
    --cc=jj@chaosbits.net \
    --cc=kjhall@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mail@srajiv.net \
    --cc=munetoh@jp.ibm.com \
    --cc=sailer@watson.ibm.com \
    --cc=stefanb@us.ibm.com \
    --cc=tpmdd-devel@lists.sourceforge.net \
    --cc=tpmdd@selhorst.net \
    --cc=tpmdd@sirrix.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.