Commit 127faf9a authored by Dominik Brodowski's avatar Dominik Brodowski Committed by Linus Torvalds

[PATCH] pcmcia: BUG() if clients are kept too long

BUG if the socket's list of clients is not empty on shutdown and/or removal.
Signed-off-by: default avatarDominik Brodowski <linux@brodo.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent b3eade62
...@@ -198,13 +198,8 @@ EXPORT_SYMBOL(pcmcia_put_socket); ...@@ -198,13 +198,8 @@ EXPORT_SYMBOL(pcmcia_put_socket);
static void pcmcia_release_socket(struct class_device *class_dev) static void pcmcia_release_socket(struct class_device *class_dev)
{ {
struct pcmcia_socket *socket = class_get_devdata(class_dev); struct pcmcia_socket *socket = class_get_devdata(class_dev);
client_t *client;
while (socket->clients) { BUG_ON(socket->clients);
client = socket->clients;
socket->clients = socket->clients->next;
kfree(client);
}
complete(&socket->socket_released); complete(&socket->socket_released);
} }
...@@ -357,8 +352,6 @@ static void free_regions(memory_handle_t *list) ...@@ -357,8 +352,6 @@ static void free_regions(memory_handle_t *list)
static void shutdown_socket(struct pcmcia_socket *s) static void shutdown_socket(struct pcmcia_socket *s)
{ {
client_t **c;
cs_dbg(s, 1, "shutdown_socket\n"); cs_dbg(s, 1, "shutdown_socket\n");
/* Blank out the socket state */ /* Blank out the socket state */
...@@ -376,15 +369,7 @@ static void shutdown_socket(struct pcmcia_socket *s) ...@@ -376,15 +369,7 @@ static void shutdown_socket(struct pcmcia_socket *s)
kfree(s->config); kfree(s->config);
s->config = NULL; s->config = NULL;
} }
for (c = &s->clients; *c; ) { BUG_ON(s->clients);
if ((*c)->state & CLIENT_UNBOUND) {
client_t *d = *c;
*c = (*c)->next;
kfree(d);
} else {
c = &((*c)->next);
}
}
free_regions(&s->a_region); free_regions(&s->a_region);
free_regions(&s->c_region); free_regions(&s->c_region);
......
...@@ -907,15 +907,13 @@ int pcmcia_deregister_client(client_handle_t handle) ...@@ -907,15 +907,13 @@ int pcmcia_deregister_client(client_handle_t handle)
s = SOCKET(handle); s = SOCKET(handle);
ds_dbg(1, "deregister_client(%p)\n", handle); ds_dbg(1, "deregister_client(%p)\n", handle);
if (handle->state & if (handle->state & (CLIENT_IRQ_REQ|CLIENT_IO_REQ|CLIENT_CONFIG_LOCKED))
(CLIENT_IRQ_REQ|CLIENT_IO_REQ|CLIENT_CONFIG_LOCKED)) goto warn_out;
return CS_IN_USE;
for (i = 0; i < MAX_WIN; i++) for (i = 0; i < MAX_WIN; i++)
if (handle->state & CLIENT_WIN_REQ(i)) if (handle->state & CLIENT_WIN_REQ(i))
return CS_IN_USE; goto warn_out;
if ((handle->state & CLIENT_STALE) || if (handle->state & CLIENT_STALE) {
(handle->Attributes & INFO_MASTER_CLIENT)) {
spin_lock_irqsave(&s->lock, flags); spin_lock_irqsave(&s->lock, flags);
client = &s->clients; client = &s->clients;
while ((*client) && ((*client) != handle)) while ((*client) && ((*client) != handle))
...@@ -934,6 +932,9 @@ int pcmcia_deregister_client(client_handle_t handle) ...@@ -934,6 +932,9 @@ int pcmcia_deregister_client(client_handle_t handle)
} }
return CS_SUCCESS; return CS_SUCCESS;
warn_out:
printk(KERN_WARNING "ds: deregister_client was called too early.\n");
return CS_IN_USE;
} /* deregister_client */ } /* deregister_client */
EXPORT_SYMBOL(pcmcia_deregister_client); EXPORT_SYMBOL(pcmcia_deregister_client);
......
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