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

Russell King rmk+pcmcia at arm.linux.org.uk
Wed May 5 23:01:23 BST 2004

On Wed, May 05, 2004 at 10:47:05AM +0300, jar wrote:
> komujun at nifty.com wrote:
> > linux/drivers/pcmcia/rsrc_mgr.c in 2.6.x is rewritten,
> > and not same as rsrc_mgr.c in 2.4.x.
> > 
> > The PD6729 driver works properly 
> > if you remove SS_CAP_PAGE_REGS from the pd6729.c.
> > This suggests find_mem_region has some problem 
> > and can not find proper memory region.
> I have already do that. The PD6729 driver _is_ _working_ very well and
> it should be added to the kernel sources I think.

It's still buggy.  Here's some further comments:

+       for (i = 0; i < MAX_SOCKETS; i++) {
+               sockets[i] = kmalloc(sizeof(struct pd6729_socket), GFP_KERNEL);
+               memset(sockets[i], 0, sizeof(*sockets[i]));
+               if (!sockets[i])
+                       return -ENOMEM;
+       }

1. This allocates "MAX_SOCKETS" worth of data.  If any allocation fails,
   we oops the kernel due to a NULL pointer dereference.
2. If we somehow miss that, we leak memory because we haven't freed the
   sockets that we have been able to allocate.
3. sockets[] is a global static array.  If we ever encounter a machine
   which has two PCI device/functions whose device/vendor IDs are matched
   by this driver, we will overwrite this array. *BAD*.

+       if ((ret = pci_enable_device(dev)))
+               return ret;

We're leaking memory we allocated above.

Can someone provide me with the output of 'lspci' of a system using
this cardbus bridge please?

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