parport: parport_pc, do not remove parent devices early
[sfrench/cifs-2.6.git] / drivers / parport / parport_pc.c
index f721299eb1baee70059a2ac33bdb8b73ba249dae..5306eb537d107f014d019f3556126dcde2a0f65e 100644 (file)
@@ -3340,13 +3340,14 @@ static void __exit parport_pc_exit(void)
        while (!list_empty(&ports_list)) {
                struct parport_pc_private *priv;
                struct parport *port;
+               struct device *dev;
                priv = list_entry(ports_list.next,
                                  struct parport_pc_private, list);
                port = priv->port;
-               if (port->dev && port->dev->bus == &platform_bus_type)
-                       platform_device_unregister(
-                               to_platform_device(port->dev));
+               dev = port->dev;
                parport_pc_unregister_port(port);
+               if (dev && dev->bus == &platform_bus_type)
+                       platform_device_unregister(to_platform_device(dev));
        }
 }