* [PATCH] pcmcia/pcmcia_resource.c: fix crash when using Cardbus cards
@ 2006-04-14 15:42 Daniel Ritz
2006-04-14 16:20 ` Dominik Brodowski
2006-04-14 20:59 ` Benjamin Herrenschmidt
0 siblings, 2 replies; 4+ messages in thread
From: Daniel Ritz @ 2006-04-14 15:42 UTC (permalink / raw)
To: Dominik Brodowski, Benjamin Herrenschmidt; +Cc: linux-pcmcia, linux-kernel
[PATCH] pcmcia/pcmcia_resource.c: fix crash when using Cardbus cards
using the old ioctl interface together with cardbus card gives a NULL
pointer dereference since cardbus devices don't have a struct pcmcia_device.
also s->io[0].res can be NULL as well.
fix is to move the pcmcia code after the cardbus code and to check for a null
pointer.
Signed-off-by: Daniel Ritz <daniel.ritz@gmx.ch>
diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c
index 45063b4..6572f07 100644
--- a/drivers/pcmcia/pcmcia_resource.c
+++ b/drivers/pcmcia/pcmcia_resource.c
@@ -209,7 +209,6 @@ int pccard_get_configuration_info(struct
if (!(s->state & SOCKET_PRESENT))
return CS_NO_CARD;
- config->Function = p_dev->func;
#ifdef CONFIG_CARDBUS
if (s->state & SOCKET_CARDBUS) {
@@ -223,14 +222,22 @@ #ifdef CONFIG_CARDBUS
config->AssignedIRQ = s->irq.AssignedIRQ;
if (config->AssignedIRQ)
config->Attributes |= CONF_ENABLE_IRQ;
- config->BasePort1 = s->io[0].res->start;
- config->NumPorts1 = s->io[0].res->end - config->BasePort1 + 1;
+ if (s->io[0].res) {
+ config->BasePort1 = s->io[0].res->start;
+ config->NumPorts1 = s->io[0].res->end - config->BasePort1 + 1;
+ }
}
return CS_SUCCESS;
}
#endif
- c = (p_dev) ? p_dev->function_config : NULL;
+ if (p_dev) {
+ c = p_dev->function_config;
+ config->Function = p_dev->func;
+ } else {
+ c = NULL;
+ config->Function = 0;
+ }
if ((c == NULL) || !(c->state & CONFIG_LOCKED)) {
config->Attributes = 0;
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] pcmcia/pcmcia_resource.c: fix crash when using Cardbus cards
2006-04-14 15:42 [PATCH] pcmcia/pcmcia_resource.c: fix crash when using Cardbus cards Daniel Ritz
@ 2006-04-14 16:20 ` Dominik Brodowski
2006-04-14 20:59 ` Benjamin Herrenschmidt
2006-04-14 20:59 ` Benjamin Herrenschmidt
1 sibling, 1 reply; 4+ messages in thread
From: Dominik Brodowski @ 2006-04-14 16:20 UTC (permalink / raw)
To: Daniel Ritz; +Cc: Benjamin Herrenschmidt, linux-pcmcia, linux-kernel
On Fri, Apr 14, 2006 at 05:42:13PM +0200, Daniel Ritz wrote:
> [PATCH] pcmcia/pcmcia_resource.c: fix crash when using Cardbus cards
Applied to pcmcia-git, thanks.
Dominik
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] pcmcia/pcmcia_resource.c: fix crash when using Cardbus cards
2006-04-14 16:20 ` Dominik Brodowski
@ 2006-04-14 20:59 ` Benjamin Herrenschmidt
0 siblings, 0 replies; 4+ messages in thread
From: Benjamin Herrenschmidt @ 2006-04-14 20:59 UTC (permalink / raw)
To: Dominik Brodowski; +Cc: Daniel Ritz, linux-pcmcia, linux-kernel
On Fri, 2006-04-14 at 18:20 +0200, Dominik Brodowski wrote:
> On Fri, Apr 14, 2006 at 05:42:13PM +0200, Daniel Ritz wrote:
> > [PATCH] pcmcia/pcmcia_resource.c: fix crash when using Cardbus cards
>
> Applied to pcmcia-git, thanks.
Thanks. Dominik, can you make sure this hits upstream before 2.6.17 ?
Cheers,
Ben.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] pcmcia/pcmcia_resource.c: fix crash when using Cardbus cards
2006-04-14 15:42 [PATCH] pcmcia/pcmcia_resource.c: fix crash when using Cardbus cards Daniel Ritz
2006-04-14 16:20 ` Dominik Brodowski
@ 2006-04-14 20:59 ` Benjamin Herrenschmidt
1 sibling, 0 replies; 4+ messages in thread
From: Benjamin Herrenschmidt @ 2006-04-14 20:59 UTC (permalink / raw)
To: Daniel Ritz; +Cc: Dominik Brodowski, linux-pcmcia, linux-kernel
On Fri, 2006-04-14 at 17:42 +0200, Daniel Ritz wrote:
> [PATCH] pcmcia/pcmcia_resource.c: fix crash when using Cardbus cards
>
> using the old ioctl interface together with cardbus card gives a NULL
> pointer dereference since cardbus devices don't have a struct pcmcia_device.
> also s->io[0].res can be NULL as well.
>
> fix is to move the pcmcia code after the cardbus code and to check for a null
> pointer.
Also note that when the card is inserted, cardctl info does print some
useful infos while pccardctl info will display nothing (empty strings).
Ben.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-04-14 21:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-14 15:42 [PATCH] pcmcia/pcmcia_resource.c: fix crash when using Cardbus cards Daniel Ritz
2006-04-14 16:20 ` Dominik Brodowski
2006-04-14 20:59 ` Benjamin Herrenschmidt
2006-04-14 20:59 ` Benjamin Herrenschmidt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®