Skip to content

Commit

Permalink
platform driver: fix use-after-free in platform_device_del()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
jeromemarchand authored and gregkh committed Aug 31, 2016
1 parent bea5b15 commit c90aab9
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions drivers/base/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
Expand Down

0 comments on commit c90aab9

Please sign in to comment.