Re: [PATCH] Infineon TPM: move infineon driver off pci_dev

From: Andrew Morton
Date: Thu Oct 27 2005 - 16:33:25 EST


Marcel Selhorst <selhorst@xxxxxxxxxxxxx> wrote:
>
> @@ -489,67 +464,51 @@ static int __devinit tpm_inf_probe(struc
> "product id %02x%02x"
> "%s\n",
> TPM_INF_ADDR,
> - tpm_inf.base,
> + TPM_INF_BASE,
> version[0], version[1],
> vendorid[0], vendorid[1],
> productid[0], productid[1], chipname);
>
> - rc = tpm_register_hardware(&pci_dev->dev, &tpm_inf);
> - if (rc < 0)
> - goto error;
> + rc = tpm_register_hardware(&dev->dev, &tpm_inf);
> + if (rc < 0) {
> + release_region(tpm_inf.base, TPM_INF_PORT_LEN);
> + return -ENODEV;
> + }
> return 0;
> } else {
> - dev_info(&pci_dev->dev, "No Infineon TPM found!\n");
> -error:
> - pnp_unregister_driver(&tpm_inf_pnp);
> -error2:
> - pci_disable_device(pci_dev);
> - pnp_registered = 0;
> + dev_info(&dev->dev, "No Infineon TPM found!\n");
> return -ENODEV;
> }
> }

This final return will leak the I/O region from request_region().

To reduce the chance of this happening again, please send a followup patch
which prevents this function from having `return' statements sprinkled all
over it. An example would be drivers/net/8139cp.c:cp_init_one(), thanks.

If for some reason the leak is deliberate then a comment is needed.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/