lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140721234330.GA6482@obsidianresearch.com>
Date:	Mon, 21 Jul 2014 17:43:30 -0600
From:	Jason Gunthorpe <jgunthorpe@...idianresearch.com>
To:	Peter Huewe <peterhuewe@....de>
Cc:	tpmdd-devel@...ts.sourceforge.net,
	LKML <linux-kernel@...r.kernel.org>
Subject: Re: [tpmdd-devel] [PATCH] Use devm_ioremap_resource to reserve
 resource

On Tue, Jul 22, 2014 at 01:26:05AM +0200, Peter Huewe wrote:
> Unfortunately the tpm_tis driver did never call request_region for its
> adress space - now since we've got devm_ioremap_resource we can simply
> remove all the stuff and do everything in one call.
> 
> Cc: <stable@...r.kernel.org>
> Signed-off-by: Peter Huewe <peterhuewe@....de>
>  drivers/char/tpm/tpm_tis.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
> index 2c46734..a79be26 100644
> +++ b/drivers/char/tpm/tpm_tis.c
> @@ -534,13 +534,14 @@ static int tpm_tis_init(struct device *dev, resource_size_t start,
>  	u32 vendor, intfcaps, intmask;
>  	int rc, i, irq_s, irq_e, probe;
>  	struct tpm_chip *chip;
> +	struct resource res = DEFINE_RES_MEM_NAMED(start, len, "tpm_tis");
>  
>  	if (!(chip = tpm_register_hardware(dev, &tpm_tis)))
>  		return -ENODEV;
>  
> -	chip->vendor.iobase = ioremap(start, len);
> -	if (!chip->vendor.iobase) {
> -		rc = -EIO;
> +	chip->vendor.iobase = devm_ioremap_resource(dev, &res);
> +	if (IS_ERR(chip->vendor.iobase)) {
> +		rc = PTR_ERR(chip->vendor.iobase);
>  		goto out_err;
>  	}
>  
> @@ -727,8 +728,6 @@ static int tpm_tis_init(struct device *dev, resource_size_t start,
>  
>  	return 0;
>  out_err:
> -	if (chip->vendor.iobase)
> -		iounmap(chip->vendor.iobase);
>  	tpm_remove_hardware(chip->dev);
>  	return rc;
>  }
> @@ -891,7 +890,6 @@ static void __exit cleanup_tis(void)
>  		release_locality(chip, chip->vendor.locality, 1);
>  		if (chip->vendor.irq)
>  			free_irq(chip->vendor.irq, chip);
> -		iounmap(i->iobase);
>  		list_del(&i->list);
>  	}

Hurm, this makes the ordering truely horrible and opaque. Are you
completely certain that in every case the devm unwide will happen only
after cleanup_tis is called?

Intuitively, I would expect all devices to have been detached and
resources freed prior to the module exit function being called...

I'd be much happier with mixing devm into this driver if it had a
proper driver remove method and the unnecessary tis_chips list was
purged.

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ