2.6.x kernels & PCI-to-PCMCIA bridges [again]

Russell King rmk+pcmcia at arm.linux.org.uk
Sun May 30 13:58:56 EDT 2004


On Sun, May 30, 2004 at 02:43:37PM +0900, komujun at nifty.com wrote:
> +	/* Register the interrupt handler */
> +	if ((ret = request_irq(dev->irq, pd6729_interrupt, SA_SHIRQ, "pd6729", socke
> t))) {
> +		printk(KERN_ERR "pd6729: Failed to register irq %d, aborting\n", dev->irq);
> +		goto err_out_free_res;
> +	}

Ok, so you claim the interrupt using a devid of "socket" - that's fine.

> +
> +	for (i = 0; i<MAX_SOCKETS; i++) {
> +		ret = pcmcia_register_socket(&socket[i]->socket);
> +		if (ret) {
> +			printk(KERN_INFO "pd6729: pcmcia_register_socket failed.\n");
> +			goto err_out_free_res2;
> +		}
> +	}

You register some sockets, but if you get an error, you aren't
unregistering the sockets which may still be registered (0 .. i - 1).

> +
> +	return 0;
> +
> +err_out_free_res2:
> +	free_irq(dev->irq, pd6729_interrupt);

And you free the IRQ using a devid of "pd6729_interrupt", which will
fail because you registered using a devid of "socket".

>...
> +static void __devexit pd6729_pci_remove(struct pci_dev *dev)
> +{
> +	int i;
> +	struct pd6729_socket **socket = pci_get_drvdata(dev);
> +
> +	for (i = MAX_SOCKETS-1; i >=0 ; i--)
> +		pcmcia_unregister_socket(&socket[i]->socket);
> +
> +	free_irq(dev->irq, pd6729_interrupt);

And exactly the same again here.

So, if you insert and remove the module, you're going to leave the
interrupt handler hooks behind and it _will_ cause a kernel oops.

Yes, we're getting closer to having a relatively bug free driver...

-- 
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 PCMCIA      - http://pcmcia.arm.linux.org.uk/
                 2.6 Serial core



More information about the linux-pcmcia mailing list