linux/drivers/base
Jean Delvare dc4c15d44b platform: reorder platform_device_del
In platform_device_del(), we currently delete the device resources
first, then we delete the device itself. This causes a (minor) bug to
occur when one unregisters a platform device before unregistering its
platform driver, and the driver is requesting (in .probe()) and
releasing (in .remove()) a resource of the device. The device
resources are already gone by the time the driver gets the chance to
release the resources it had been requesting, causing an error like:
Trying to free nonexistent resource <0000000000000295-0000000000000296>

If the platform driver is unregistered first, the problem doesn't
occur, as the driver will have the opportunity to release the
resources it had requested before the device resources themselves are
released. It's a bit odd that unregistering the driver first or the
device first doesn't lead to the same result.

So I believe that we should delete the device first in
platform_device_del(). I've searched the git history and found that it
used to be the case before 2.6.8, but was changed here:

http://www.kernel.org/git/?p=linux/kernel/git/torvalds/old-2.6-bkcvs.git;a=commitdiff;h=96ef7b3689936ee1e64b711511342026a8ce459c

> 2004/07/14 16:09:44-07:00 dtor_core
> [PATCH] Driver core: Fix OOPS in device_platform_unregister
> 
> Driver core: platform_device_unregister should release resources first
>              and only then call device_unregister, otherwise if there
>              are no more references to the device it will be freed and
>              the fucntion will try to access freed memory.  

However we now have an explicit call to put_device() at the end of
platform_device_unregister() so I guess the original problem no longer
exists and it is safe to revert that change.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2007-05-02 18:57:59 -07:00
..
power define platform wakeup hook, use in pci_enable_wake() 2007-04-27 10:57:33 -07:00
attribute_container.c drivers/base/attribute_container.c: use mutex instead of binary semaphore 2007-04-27 10:57:34 -07:00
base.h driver core: don't fail attaching the device if it cannot be bound 2007-04-27 10:57:29 -07:00
bus.c driver core: bus_add_driver should return an error if no bus 2007-04-27 10:57:32 -07:00
class.c driver core: fix namespace issue with devices assigned to classes 2007-04-27 10:57:28 -07:00
core.c Driver core: fix show_uevent from taking up way too much stack 2007-05-02 18:57:59 -07:00
cpu.c
dd.c driver core: don't fail attaching the device if it cannot be bound 2007-04-27 10:57:29 -07:00
devres.c
dma-mapping.c
dmapool.c Driver core: use mutex instead of semaphore in DMA pool handler 2007-04-27 10:57:32 -07:00
driver.c Driver core: remove unneeded completion from driver release path 2007-04-27 10:57:29 -07:00
firmware_class.c Driver core: switch firmware_class to uevent_suppress. 2007-04-27 10:57:29 -07:00
firmware.c
hypervisor.c
init.c
isa.c
Kconfig
Makefile
map.c
memory.c
node.c
platform.c platform: reorder platform_device_del 2007-05-02 18:57:59 -07:00
sys.c
topology.c
transport_class.c