Skip to content

Commit

Permalink
[PATCH] pcmcia/pcmcia_resource.c: fix crash when using Cardbus cards
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
  • Loading branch information
Daniel Ritz authored and Dominik Brodowski committed Apr 21, 2006
1 parent daaeb72 commit 48b950f
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions drivers/pcmcia/pcmcia_resource.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ int pccard_get_configuration_info(struct pcmcia_socket *s,
if (!(s->state & SOCKET_PRESENT))
return CS_NO_CARD;

config->Function = p_dev->func;

#ifdef CONFIG_CARDBUS
if (s->state & SOCKET_CARDBUS) {
Expand All @@ -222,14 +221,22 @@ int pccard_get_configuration_info(struct pcmcia_socket *s,
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;
Expand Down

0 comments on commit 48b950f

Please sign in to comment.