mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] pcmcia: Fix broken abuse of dev->driver_data
@ 2008-09-22 14:58 Alan Cox
  2008-09-22 21:56 ` Dominik Brodowski
  0 siblings, 1 reply; 15+ messages in thread
From: Alan Cox @ 2008-09-22 14:58 UTC (permalink / raw)
  To: torvalds, linux-kernel

From: Alan Cox <alan@redhat.com>

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>
---

 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 4174d96..853d342 100644
--- a/drivers/pcmcia/ds.c
+++ b/drivers/pcmcia/ds.c
@@ -426,6 +426,18 @@ static int pcmcia_device_probe(struct device * dev)
 	p_dev = to_pcmcia_dev(dev);
 	p_drv = to_pcmcia_drv(dev->driver);
 	s = p_dev->socket;
+	
+	/* The PCMCIA code passes the match data in via dev->driver_data
+	 * which is an ugly hack. Once the driver probe is called it may
+	 * and often will overwrite the match data so we must save it first 
+	 *
+	 * handle pseudo multifunction devices:
+	 * there are at most two pseudo multifunction devices.
+	 * if we're matching against the first, schedule a
+	 * call which will then check whether there are two
+	 * pseudo devices, and if not, add the second one.
+	 */
+	did = p_dev->dev.driver_data;
 
 	ds_dbg(1, "trying to bind %s to %s\n", p_dev->dev.bus_id,
 	       p_drv->drv.name);
@@ -455,21 +467,14 @@ static int pcmcia_device_probe(struct device * dev)
 		goto put_module;
 	}
 
-	/* handle pseudo multifunction devices:
-	 * there are at most two pseudo multifunction devices.
-	 * if we're matching against the first, schedule a
-	 * call which will then check whether there are two
-	 * pseudo devices, and if not, add the second one.
-	 */
-	did = p_dev->dev.driver_data;
 	if (did && (did->match_flags & PCMCIA_DEV_ID_MATCH_DEVICE_NO) &&
 	    (p_dev->socket->device_count == 1) && (p_dev->device_no ==
0)) pcmcia_add_device_later(p_dev->socket, 0);
 
- put_module:
+put_module:
 	if (ret)
 		module_put(p_drv->owner);
- put_dev:
+put_dev:
 	if (ret)
 		put_device(dev);
 	return (ret);
--
<meme>discombobulated echidna</meme>

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2008-11-02 13:37 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-22 14:58 [PATCH] pcmcia: Fix broken abuse of dev->driver_data Alan Cox
2008-09-22 21:56 ` Dominik Brodowski
2008-09-22 22:12   ` Alan Cox
2008-09-22 22:26     ` Dominik Brodowski
2008-09-22 23:15       ` Alan Cox
2008-09-23  1:31         ` Komuro
2008-09-26 13:29         ` [PATCH git latest] drivers/net: fixing a datarace related to update_stats() Komuro
2008-09-26 16:06           ` Tammy
2008-09-26 17:31           ` Lin Tan
2008-11-01  2:07       ` [BUG REPORT!!!] [PATCH 19/49] pcmcia: remove remaining in-kernel pcmcia_get_configuration_info() users Komuro
2008-11-02  8:46         ` Komuro
2008-11-02  9:17           ` Dominik Brodowski
2008-11-02 10:33             ` Komuro
2008-11-02 12:04               ` Dominik Brodowski
2008-10-06 12:18     ` [PATCH 03/19] pcmcia: Whine harder about use of EXCLUSIVE Komuro

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®