diff options
author | Daniel Ritz <daniel.ritz-ml@swissonline.ch> | 2006-04-14 17:42:13 +0200 |
---|---|---|
committer | Dominik Brodowski <linux@dominikbrodowski.net> | 2006-04-22 00:49:19 +0200 |
commit | 48b950ff241fca03a6969a5eb6a42a02722678d4 (patch) | |
tree | d6a5fb6080355af987b7d60e5308b68d85d85ae7 /drivers/pcmcia/pcmcia_resource.c | |
parent | daaeb72bdf22873e6fa6497550c9e1d9a8825fea (diff) | |
download | blackbird-op-linux-48b950ff241fca03a6969a5eb6a42a02722678d4.tar.gz blackbird-op-linux-48b950ff241fca03a6969a5eb6a42a02722678d4.zip |
[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>
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/pcmcia/pcmcia_resource.c')
-rw-r--r-- | drivers/pcmcia/pcmcia_resource.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c index cc3402c9b2c3..3131bb0a0095 100644 --- a/drivers/pcmcia/pcmcia_resource.c +++ b/drivers/pcmcia/pcmcia_resource.c @@ -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) { @@ -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; |