mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@osdl.org>
To: Dmitry Torokhov <dtor_core@ameritech.net>
Cc: linux-kernel@vger.kernel.org, stelian@popies.net, malattia@linux.it
Subject: Re: [PATCH] Sonypi: convert to the new platform device interface
Date: Tue, 13 Dec 2005 22:08:53 -0800	[thread overview]
Message-ID: <20051213220853.6e620c59.akpm@osdl.org> (raw)
In-Reply-To: <200512140041.16711.dtor_core@ameritech.net>

Dmitry Torokhov <dtor_core@ameritech.net> wrote:
>
> Sonypi: convert to the new platform device interface
> 
> Do not use platform_device_register_simple() as it is going away,
> implement ->probe() and -remove() functions so manual binding and
> unbinding will work with this driver.
> 
> ...
>
>  	return 0;
> +
> + err_unregister_jogdev:
> +	input_unregister_device(jog_dev);
> +	/* Set to NULL so we don't free it again below */
> +	jog_dev = NULL;
> + err_free_keydev:
> +	input_free_device(key_dev);
> +	sonypi_device.input_key_dev = NULL;
> + err_free_jogdev:
> +	input_unregister_device(jog_dev);
> +	sonypi_device.input_jog_dev = NULL;
> +
> +	return error;
>  }

The error unwinding here is mucked up - err_free_jogdev will unregister a
not-registered device.

> +static int __devinit sonypi_probe(struct platform_device *dev)

And I have my doubts about this function too.

> +{
> +	const struct sonypi_ioport_list *ioport_list;
> +	const struct sonypi_irq_list *irq_list;
> +	struct pci_dev *pcidev;
> +	int error;
>  
>  	spin_lock_init(&sonypi_device.fifo_lock);
>  	sonypi_device.fifo = kfifo_alloc(SONYPI_BUF_SIZE, GFP_KERNEL,
>  					 &sonypi_device.fifo_lock);
>  	if (IS_ERR(sonypi_device.fifo)) {
>  		printk(KERN_ERR "sonypi: kfifo_alloc failed\n");
> -		ret = PTR_ERR(sonypi_device.fifo);
> -		goto out_fifo;
> +		return PTR_ERR(sonypi_device.fifo);
>  	}
>  
>  	init_waitqueue_head(&sonypi_device.fifo_proc_list);
>  	init_MUTEX(&sonypi_device.lock);
>  	sonypi_device.bluetooth_power = -1;
>  
> +	if ((pcidev = pci_get_device(PCI_VENDOR_ID_INTEL,
> +				     PCI_DEVICE_ID_INTEL_82371AB_3, NULL)))
> +		sonypi_device.model = SONYPI_DEVICE_MODEL_TYPE1;
> +	else if ((pcidev = pci_get_device(PCI_VENDOR_ID_INTEL,
> +					  PCI_DEVICE_ID_INTEL_ICH6_1, NULL)))
> +		sonypi_device.model = SONYPI_DEVICE_MODEL_TYPE3;
> +	else
> +		sonypi_device.model = SONYPI_DEVICE_MODEL_TYPE2;
> +
>  	if (pcidev && pci_enable_device(pcidev)) {
>  		printk(KERN_ERR "sonypi: pci_enable_device failed\n");
> -		ret = -EIO;
> -		goto out_pcienable;
> -	}
> -
> -	if (minor != -1)
> -		sonypi_misc_device.minor = minor;
> -	if ((ret = misc_register(&sonypi_misc_device))) {
> -		printk(KERN_ERR "sonypi: misc_register failed\n");
> -		goto out_miscreg;
> +		error = -EIO;
> +		goto err_free_fifo;

err_free_fifo doesn't do pci_dev_put().  So if we have a pci_device but
pci_enabe_device() failed we leak a refcount I think.

Anyway, please triple-check all that error path code, resend?

  reply	other threads:[~2005-12-14  6:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-14  5:41 Dmitry Torokhov
2005-12-14  6:08 ` Andrew Morton [this message]
2005-12-14  6:58   ` Dmitry Torokhov
2005-12-14  5:46 Yu, Luming
2005-12-14  5:56 ` Dmitry Torokhov
2005-12-14  5:57 ` Andrew Morton
2005-12-14  9:07   ` Stelian Pop

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=20051213220853.6e620c59.akpm@osdl.org \
    --to=akpm@osdl.org \
    --cc=dtor_core@ameritech.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=malattia@linux.it \
    --cc=stelian@popies.net \
    /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

Powered by JetHome