Commit 36e9d08b authored by Boris Brezillon's avatar Boris Brezillon Committed by Dave Airlie

drm/cirrus: Fix NULL pointer dereference when registering the fbdev

cirrus_modeset_init() is initializing/registering the emulated fbdev
and, since commit c61b93fe ("drm/atomic: Fix remaining places where
!funcs->best_encoder is valid"), DRM internals can access/test some of
the fields in mode_config->funcs as part of the fbdev registration
process.
Make sure dev->mode_config.funcs is properly set to avoid dereferencing
a NULL pointer.
Reported-by: default avatarMike Marshall <hubcap@omnibond.com>
Reported-by: default avatarEric W. Biederman <ebiederm@xmission.com>
Signed-off-by: default avatarBoris Brezillon <boris.brezillon@free-electrons.com>
Fixes: c61b93fe ("drm/atomic: Fix remaining places where !funcs->best_encoder is valid")
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent 210a021d
...@@ -185,14 +185,23 @@ int cirrus_driver_load(struct drm_device *dev, unsigned long flags) ...@@ -185,14 +185,23 @@ int cirrus_driver_load(struct drm_device *dev, unsigned long flags)
goto out; goto out;
} }
/*
* cirrus_modeset_init() is initializing/registering the emulated fbdev
* and DRM internals can access/test some of the fields in
* mode_config->funcs as part of the fbdev registration process.
* Make sure dev->mode_config.funcs is properly set to avoid
* dereferencing a NULL pointer.
* FIXME: mode_config.funcs assignment should probably be done in
* cirrus_modeset_init() (that's a common pattern seen in other DRM
* drivers).
*/
dev->mode_config.funcs = &cirrus_mode_funcs;
r = cirrus_modeset_init(cdev); r = cirrus_modeset_init(cdev);
if (r) { if (r) {
dev_err(&dev->pdev->dev, "Fatal error during modeset init: %d\n", r); dev_err(&dev->pdev->dev, "Fatal error during modeset init: %d\n", r);
goto out; goto out;
} }
dev->mode_config.funcs = (void *)&cirrus_mode_funcs;
return 0; return 0;
out: out:
cirrus_driver_unload(dev); cirrus_driver_unload(dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment