aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Ritz <daniel.ritz-ml@swissonline.ch>2006-04-14 11:42:13 -0400
committerDominik Brodowski <linux@dominikbrodowski.net>2006-04-21 18:49:19 -0400
commit48b950ff241fca03a6969a5eb6a42a02722678d4 (patch)
treed6a5fb6080355af987b7d60e5308b68d85d85ae7
parentdaaeb72bdf22873e6fa6497550c9e1d9a8825fea (diff)
[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>
-rw-r--r--drivers/pcmcia/pcmcia_resource.c15
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,
208 if (!(s->state & SOCKET_PRESENT)) 208 if (!(s->state & SOCKET_PRESENT))
209 return CS_NO_CARD; 209 return CS_NO_CARD;
210 210
211 config->Function = p_dev->func;
212 211
213#ifdef CONFIG_CARDBUS 212#ifdef CONFIG_CARDBUS
214 if (s->state & SOCKET_CARDBUS) { 213 if (s->state & SOCKET_CARDBUS) {
@@ -222,14 +221,22 @@ int pccard_get_configuration_info(struct pcmcia_socket *s,
222 config->AssignedIRQ = s->irq.AssignedIRQ; 221 config->AssignedIRQ = s->irq.AssignedIRQ;
223 if (config->AssignedIRQ) 222 if (config->AssignedIRQ)
224 config->Attributes |= CONF_ENABLE_IRQ; 223 config->Attributes |= CONF_ENABLE_IRQ;
225 config->BasePort1 = s->io[0].res->start; 224 if (s->io[0].res) {
226 config->NumPorts1 = s->io[0].res->end - config->BasePort1 + 1; 225 config->BasePort1 = s->io[0].res->start;
226 config->NumPorts1 = s->io[0].res->end - config->BasePort1 + 1;
227 }
227 } 228 }
228 return CS_SUCCESS; 229 return CS_SUCCESS;
229 } 230 }
230#endif 231#endif
231 232
232 c = (p_dev) ? p_dev->function_config : NULL; 233 if (p_dev) {
234 c = p_dev->function_config;
235 config->Function = p_dev->func;
236 } else {
237 c = NULL;
238 config->Function = 0;
239 }
233 240
234 if ((c == NULL) || !(c->state & CONFIG_LOCKED)) { 241 if ((c == NULL) || !(c->state & CONFIG_LOCKED)) {
235 config->Attributes = 0; 242 config->Attributes = 0;