aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/platform.c
diff options
context:
space:
mode:
authorJerome Marchand <jmarchan@redhat.com>2016-07-25 16:13:32 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-08-31 15:13:56 +0200
commitc90aab9c96c2a7f7bf3f7a54167dc5c0ba2b178c (patch)
treee8fddbf53d62ad80abdad94327453010567bef2c /drivers/base/platform.c
parentbea5b158ff0da9c7246ff391f754f5f38e34577a (diff)
downloadlinux-c90aab9c96c2a7f7bf3f7a54167dc5c0ba2b178c.tar.gz
platform driver: fix use-after-free in platform_device_del()
In platform_device_del(), the device is still used after a call to device_del(). At this point there is no guarantee that the device is still there and there could be a use-after-free access. Move the call to device_remove_properties() before device_del() to fix that. Signed-off-by: Jerome Marchand <jmarchan@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/base/platform.c')
-rw-r--r--drivers/base/platform.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 6482d47deb507..f57fff3f268b6 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -434,6 +434,7 @@ void platform_device_del(struct platform_device *pdev)
int i;
if (pdev) {
+ device_remove_properties(&pdev->dev);
device_del(&pdev->dev);
if (pdev->id_auto) {
@@ -446,8 +447,6 @@ void platform_device_del(struct platform_device *pdev)
if (r->parent)
release_resource(r);
}
-
- device_remove_properties(&pdev->dev);
}
}
EXPORT_SYMBOL_GPL(platform_device_del);