diff options
author | Alan Cox <alan@redhat.com> | 2008-09-22 10:58:14 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-09-22 11:42:50 -0400 |
commit | cec5eb7be3a104fffd27ca967ee8e15a123050e2 (patch) | |
tree | bf5579c6e47a120d5ba59aa6f90bb29ad96817f5 | |
parent | ae9111912500db9fcc244ec16c3d7e471c551f52 (diff) |
pcmcia: Fix broken abuse of dev->driver_data
PCMCIA abuses dev->private_data in the probe methods. Unfortunately it
continues to abuse it after calling drv->probe() which leads to crashes and
other nasties (such as bogus probes of multifunction devices) giving errors like
pcmcia: registering new device pcmcia0.1
kernel: 0.1: GetNextTuple: No more items
Extract the passed data before calling the driver probe function that way
we don't blow up when the driver reuses dev->private_data as its right.
As its close to the final release just move the hack so it works out,
hopefully someone will be sufficiently embarrassed to produce a nice rework
for 2.6.28.
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | drivers/pcmcia/ds.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index 4174d9656e35..34c83d3ca0fa 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c | |||
@@ -427,6 +427,18 @@ static int pcmcia_device_probe(struct device * dev) | |||
427 | p_drv = to_pcmcia_drv(dev->driver); | 427 | p_drv = to_pcmcia_drv(dev->driver); |
428 | s = p_dev->socket; | 428 | s = p_dev->socket; |
429 | 429 | ||
430 | /* The PCMCIA code passes the match data in via dev->driver_data | ||
431 | * which is an ugly hack. Once the driver probe is called it may | ||
432 | * and often will overwrite the match data so we must save it first | ||
433 | * | ||
434 | * handle pseudo multifunction devices: | ||
435 | * there are at most two pseudo multifunction devices. | ||
436 | * if we're matching against the first, schedule a | ||
437 | * call which will then check whether there are two | ||
438 | * pseudo devices, and if not, add the second one. | ||
439 | */ | ||
440 | did = p_dev->dev.driver_data; | ||
441 | |||
430 | ds_dbg(1, "trying to bind %s to %s\n", p_dev->dev.bus_id, | 442 | ds_dbg(1, "trying to bind %s to %s\n", p_dev->dev.bus_id, |
431 | p_drv->drv.name); | 443 | p_drv->drv.name); |
432 | 444 | ||
@@ -455,21 +467,14 @@ static int pcmcia_device_probe(struct device * dev) | |||
455 | goto put_module; | 467 | goto put_module; |
456 | } | 468 | } |
457 | 469 | ||
458 | /* handle pseudo multifunction devices: | ||
459 | * there are at most two pseudo multifunction devices. | ||
460 | * if we're matching against the first, schedule a | ||
461 | * call which will then check whether there are two | ||
462 | * pseudo devices, and if not, add the second one. | ||
463 | */ | ||
464 | did = p_dev->dev.driver_data; | ||
465 | if (did && (did->match_flags & PCMCIA_DEV_ID_MATCH_DEVICE_NO) && | 470 | if (did && (did->match_flags & PCMCIA_DEV_ID_MATCH_DEVICE_NO) && |
466 | (p_dev->socket->device_count == 1) && (p_dev->device_no == 0)) | 471 | (p_dev->socket->device_count == 1) && (p_dev->device_no == 0)) |
467 | pcmcia_add_device_later(p_dev->socket, 0); | 472 | pcmcia_add_device_later(p_dev->socket, 0); |
468 | 473 | ||
469 | put_module: | 474 | put_module: |
470 | if (ret) | 475 | if (ret) |
471 | module_put(p_drv->owner); | 476 | module_put(p_drv->owner); |
472 | put_dev: | 477 | put_dev: |
473 | if (ret) | 478 | if (ret) |
474 | put_device(dev); | 479 | put_device(dev); |
475 | return (ret); | 480 | return (ret); |