Commit 87eaabc4 authored by Dominik Brodowski's avatar Dominik Brodowski Committed by Russell King

[PCMCIA] fix pcmcia_bind_driver

Don't allow "bind_request" to be called before "register_pccard_driver".
parent 0f5c57f5
...@@ -188,35 +188,21 @@ int register_pccard_driver(dev_info_t *dev_info, ...@@ -188,35 +188,21 @@ int register_pccard_driver(dev_info_t *dev_info,
void (*detach)(dev_link_t *)) void (*detach)(dev_link_t *))
{ {
struct pcmcia_driver *driver; struct pcmcia_driver *driver;
socket_bind_t *b;
struct pcmcia_bus_socket *bus_sock;
DEBUG(0, "ds: register_pccard_driver('%s')\n", (char *)dev_info); DEBUG(0, "ds: register_pccard_driver('%s')\n", (char *)dev_info);
driver = get_pcmcia_driver(dev_info); driver = get_pcmcia_driver(dev_info);
if (!driver) { if (driver)
driver = kmalloc(sizeof(struct pcmcia_driver), GFP_KERNEL); return -EBUSY;
if (!driver) return -ENOMEM;
memset(driver, 0, sizeof(struct pcmcia_driver)); driver = kmalloc(sizeof(struct pcmcia_driver), GFP_KERNEL);
driver->drv.name = (char *)dev_info; if (!driver) return -ENOMEM;
pcmcia_register_driver(driver); memset(driver, 0, sizeof(struct pcmcia_driver));
} driver->drv.name = (char *)dev_info;
pcmcia_register_driver(driver);
driver->attach = attach; driver->attach = attach;
driver->detach = detach; driver->detach = detach;
if (driver->use_count == 0) return 0;
/* Instantiate any already-bound devices */
down_read(&bus_socket_list_rwsem);
list_for_each_entry(bus_sock, &bus_socket_list, socket_list) {
for (b = bus_sock->bind; b; b = b->next) {
if (b->driver != driver) continue;
b->instance = driver->attach();
if (b->instance == NULL)
printk(KERN_NOTICE "ds: unable to create instance "
"of '%s'!\n", driver->drv.name);
}
}
up_read(&bus_socket_list_rwsem);
return 0; return 0;
} /* register_pccard_driver */ } /* register_pccard_driver */
...@@ -414,13 +400,8 @@ static int bind_request(struct pcmcia_bus_socket *s, bind_info_t *bind_info) ...@@ -414,13 +400,8 @@ static int bind_request(struct pcmcia_bus_socket *s, bind_info_t *bind_info)
DEBUG(2, "bind_request(%d, '%s')\n", i, DEBUG(2, "bind_request(%d, '%s')\n", i,
(char *)bind_info->dev_info); (char *)bind_info->dev_info);
driver = get_pcmcia_driver(&bind_info->dev_info); driver = get_pcmcia_driver(&bind_info->dev_info);
if (driver == NULL) { if (!driver)
driver = kmalloc(sizeof(struct pcmcia_driver), GFP_KERNEL); return -EINVAL;
if (!driver) return -ENOMEM;
memset(driver, 0, sizeof(struct pcmcia_driver));
driver->drv.name = bind_info->dev_info;
pcmcia_register_driver(driver);
}
for (b = s->bind; b; b = b->next) for (b = s->bind; b; b = b->next)
if ((driver == b->driver) && if ((driver == b->driver) &&
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment