Skip to content

Commit 1342b5b

Browse files
smaeulmripard
authored andcommitted
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: 624b4b4 ("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
1 parent 9201690 commit 1342b5b

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

drivers/gpu/drm/sun4i/sun4i_drv.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ static int sun4i_drv_bind(struct device *dev)
7373
goto free_drm;
7474
}
7575

76-
dev_set_drvdata(dev, drm);
7776
drm->dev_private = drv;
7877
INIT_LIST_HEAD(&drv->frontend_list);
7978
INIT_LIST_HEAD(&drv->engine_list);
@@ -114,6 +113,8 @@ static int sun4i_drv_bind(struct device *dev)
114113

115114
drm_fbdev_generic_setup(drm, 32);
116115

116+
dev_set_drvdata(dev, drm);
117+
117118
return 0;
118119

119120
finish_poll:
@@ -130,6 +131,7 @@ static void sun4i_drv_unbind(struct device *dev)
130131
{
131132
struct drm_device *drm = dev_get_drvdata(dev);
132133

134+
dev_set_drvdata(dev, NULL);
133135
drm_dev_unregister(drm);
134136
drm_kms_helper_poll_fini(drm);
135137
drm_atomic_helper_shutdown(drm);

0 commit comments

Comments
 (0)