drm/sun4i: Fix crash during suspend after component bind failure
authorSamuel Holland <samuel@sholland.org>
Wed, 15 Jun 2022 05:42:53 +0000 (00:42 -0500)
committerMaxime Ripard <maxime@cerno.tech>
Thu, 16 Jun 2022 07:49:28 +0000 (09:49 +0200)
commit1342b5b23da9559a1578978eaff7f797d8a87d91
tree9becfd6ea20f39616eff19281fd735a9c4c93dc7
parent920169041baa0a7497ed702aa97d6a2d6285efd3
drm/sun4i: Fix crash during suspend after component bind failure

If the component driver fails to bind, or is unbound, the driver data
for the top-level platform device points to a freed drm_device. If the
system is then suspended, the driver passes this dangling pointer to
drm_mode_config_helper_suspend(), which crashes.

Fix this by only setting the driver data while the platform driver holds
a reference to the drm_device.

Fixes: 624b4b48d9d8 ("drm: sun4i: Add support for suspending the display driver")
Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Link: https://lore.kernel.org/r/20220615054254.16352-1-samuel@sholland.org
drivers/gpu/drm/sun4i/sun4i_drv.c