[patch 1/6] pcmcia: fix 'rmmod pcmcia' with unbound devices

Daniel Ritz daniel.ritz-ml at swissonline.ch
Sun Nov 19 12:46:05 EST 2006


On Sunday 19 November 2006 17.12, Dominik Brodowski wrote:
> On Sat, Nov 18, 2006 at 10:19:34PM -0800, akpm at osdl.org wrote:
> > From: Daniel Ritz <daniel.ritz-ml at swissonline.ch>
> > 
> > Having unbound PCMCIA devices: doing a 'find /sys' after a 'rmmod pcmcia'
> > gives an oops because the pcmcia_device is not unregisterd from the driver
> > core.
> > 
> > fixes bugzilla #7481
> > 
> > Signed-off-by: Daniel Ritz <daniel.ritz at gmx.ch>
> > Dominik Brodowski <linux at dominikbrodowski.net>
> > Cc: Pavol Gono <Palo.Gono at gmail.com>
> > Cc: <stable at kernel.org>
> > Signed-off-by: Andrew Morton <akpm at osdl.org>
> 
> NACK. All other calls to pcmcia_card_remove() are done with
> 
> struct pcmcia_socket -> skt_mutex
> 
> held, and the pcmcia_card_remove() and other parts of drivers/pcmcia/ds.c
> are written with this in mind. Therefore, I'd prefer this patch (which I'll
> include to pcmcia-fixes-2.6).
> 
> 
> From: Dominik Brodowski <linux at dominikbrodowski.net>
> Subject: [PATCH] pcmcia: fix 'rmmod pcmcia' with leftover devices
> 
> When removing the pcmcia module, all pcmcia devices currently registered
> must be removed, so that doing 'find /sys' does not result in an oops.
> (bugzilla #7481). Debugged and original fix by Daniel Ritz.
> 
> Signed-off-by: Dominik Brodowski <linux at dominikbrodowski.net>
> ---
>  drivers/pcmcia/cs.c |    7 ++++---
>  1 files changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c
> index f9cd831..7291db2 100644
> --- a/drivers/pcmcia/cs.c
> +++ b/drivers/pcmcia/cs.c
> @@ -728,11 +728,12 @@ int pccard_register_pcmcia(struct pcmcia
>  		}
>  
>  		s->callback = c;
> -
> -		if ((s->state & (SOCKET_PRESENT|SOCKET_CARDBUS)) == SOCKET_PRESENT)
> -			send_event(s, CS_EVENT_CARD_INSERTION, CS_EVENT_PRI_LOW);
>  	} else
>  		s->callback = NULL;
> +
> +	if ((s->state & (SOCKET_PRESENT|SOCKET_CARDBUS)) == SOCKET_PRESENT)
> +		send_event(s, c ? CS_EVENT_CARD_INSERTION :
> +			   CS_EVENT_CARD_REMOVAL, CS_EVENT_PRI_LOW);
>   err:
>  	mutex_unlock(&s->skt_mutex);
>  

NACK. does not fix the problem: ds.c:ds_event() will never be called
because s->callback is set to NULL just before send_event() which means
send_event() does nothing at all..

fix with the missed mutex:
 
Signed-off-by: Daniel Ritz <daniel.ritz at gmx.ch>

diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
index 0f70192..21d83a8 100644
--- a/drivers/pcmcia/ds.c
+++ b/drivers/pcmcia/ds.c
@@ -1271,6 +1271,11 @@ static void pcmcia_bus_remove_socket(str
 	socket->pcmcia_state.dead = 1;
 	pccard_register_pcmcia(socket, NULL);
 
+	/* unregister any unbound devices */
+	mutex_lock(&socket->skt_mutex);
+	pcmcia_card_remove(socket, NULL);
+	mutex_unlock(&socket->skt_mutex);
+
 	pcmcia_put_socket(socket);
 
 	return;





More information about the linux-pcmcia mailing list