public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Kylene Jo Hall <kjhall@us.ibm.com>
To: Jeff Garzik <jeff@garzik.org>
Cc: Andrew Morton <akpm@osdl.org>, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] tpm: fix error handling
Date: Wed, 04 Oct 2006 08:04:06 -0700	[thread overview]
Message-ID: <1159974246.6876.0.camel@localhost.localdomain> (raw)
In-Reply-To: <20061004141644.GA30669@havoc.gtf.org>

Ack'ed-by: Kylene Hall <kjhall@us.ibm.com>

On Wed, 2006-10-04 at 10:16 -0400, Jeff Garzik wrote:
> - handle sysfs error
> - handle driver model errors
> - de-obfuscate platform_device_register_simple() call, which included an
>   assignment in between two function calls, in the same C statement.
> 
> Signed-off-by: Jeff Garzik <jeff@garzik.org>
> 
> ---
> 
>  drivers/char/tpm/tpm.c       |    9 ++++++++-
>  drivers/char/tpm/tpm_atmel.c |   10 +++++-----
>  drivers/char/tpm/tpm_nsc.c   |    6 ++++--
>  3 files changed, 17 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
> index a082a2e..6ad2d3b 100644
> --- a/drivers/char/tpm/tpm.c
> +++ b/drivers/char/tpm/tpm.c
> @@ -1153,7 +1153,14 @@ #define DEVNAME_SIZE 7
>  
>  	spin_unlock(&driver_lock);
>  
> -	sysfs_create_group(&dev->kobj, chip->vendor.attr_group);
> +	if (sysfs_create_group(&dev->kobj, chip->vendor.attr_group)) {
> +		list_del(&chip->list);
> +		put_device(dev);
> +		clear_bit(chip->dev_num, dev_mask);
> +		kfree(chip);
> +		kfree(devname);
> +		return NULL;
> +	}
>  
>  	chip->bios_dir = tpm_bios_log_setup(devname);
>  
> diff --git a/drivers/char/tpm/tpm_atmel.c b/drivers/char/tpm/tpm_atmel.c
> index ad8ffe4..1ab0896 100644
> --- a/drivers/char/tpm/tpm_atmel.c
> +++ b/drivers/char/tpm/tpm_atmel.c
> @@ -184,7 +184,9 @@ static int __init init_atmel(void)
>  	unsigned long base;
>  	struct  tpm_chip *chip;
>  
> -	driver_register(&atml_drv);
> +	rc = driver_register(&atml_drv);
> +	if (rc)
> +		return rc;
>  
>  	if ((iobase = atmel_get_base_addr(&base, &region_size)) == NULL) {
>  		rc = -ENODEV;
> @@ -195,10 +197,8 @@ static int __init init_atmel(void)
>  	    (atmel_request_region
>  	     (tpm_atmel.base, region_size, "tpm_atmel0") == NULL) ? 0 : 1;
>  
> -
> -	if (IS_ERR
> -	    (pdev =
> -	     platform_device_register_simple("tpm_atmel", -1, NULL, 0))) {
> +	pdev = platform_device_register_simple("tpm_atmel", -1, NULL, 0);
> +	if (IS_ERR(pdev)) {
>  		rc = PTR_ERR(pdev);
>  		goto err_rel_reg;
>  	}
> diff --git a/drivers/char/tpm/tpm_nsc.c b/drivers/char/tpm/tpm_nsc.c
> index 26287aa..608f730 100644
> --- a/drivers/char/tpm/tpm_nsc.c
> +++ b/drivers/char/tpm/tpm_nsc.c
> @@ -284,7 +284,7 @@ static struct device_driver nsc_drv = {
>  static int __init init_nsc(void)
>  {
>  	int rc = 0;
> -	int lo, hi;
> +	int lo, hi, err;
>  	int nscAddrBase = TPM_ADDR;
>  	struct tpm_chip *chip;
>  	unsigned long base;
> @@ -297,7 +297,9 @@ static int __init init_nsc(void)
>  			return -ENODEV;
>  	}
>  
> -	driver_register(&nsc_drv);
> +	err = driver_register(&nsc_drv);
> +	if (err)
> +		return err;
>  
>  	hi = tpm_read_index(nscAddrBase, TPM_NSC_BASE0_HI);
>  	lo = tpm_read_index(nscAddrBase, TPM_NSC_BASE0_LO);


      reply	other threads:[~2006-10-04 15:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-04 14:16 [PATCH] tpm: fix error handling Jeff Garzik
2006-10-04 15:04 ` Kylene Jo Hall [this message]

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=1159974246.6876.0.camel@localhost.localdomain \
    --to=kjhall@us.ibm.com \
    --cc=akpm@osdl.org \
    --cc=jeff@garzik.org \
    --cc=linux-kernel@vger.kernel.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