Skip to contentSkip to conversation

drm/atomic: Check that the config funcs exist drm_mode_alloc

PATCH In review Jordan Crouse 2 participants 2 messages May 7, 2019 – May 8, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/atomic: Check that the config funcs exist drm_mode_alloc

An error while initializing the msm driver ends up calling drm_atomic_helper_shutdown() without first initializing the funcs in mode_config. While I'm not 100% sure this isn't a ordering problem in msm adding a check to drm_mode_alloc seems like a nice and safe solution.

---

 drivers/gpu/drm/drm_atomic.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/drm_atomic.c +3 -0
index 5eb4013..1729428 100644
@@ -114,6 +114,9 @@ drm_atomic_state_alloc(struct drm_device *dev)
 {
 	struct drm_mode_config *config = &dev->mode_config;
 
+	if (!config->funcs)
+		return NULL;
+
 	if (!config->funcs->atomic_state_alloc) {
 		struct drm_atomic_state *state;
 
Signature · 1 line
2.7.4
#1 lore raw
Quoted 7 lines · Jordan Crouse

An error while initializing the msm driver ends up calling drm_atomic_helper_shutdown() without first initializing the funcs in mode_config. While I'm not 100% sure this isn't a ordering problem in msm adding a check to drm_mode_alloc seems like a nice and safe solution.

Hm yeah this looks a bit too much like ducttape. I think Noralf started working on some ideas of devm-like automatic cleanup for drm stuff (we cannot use devm, that has the wrong lifetimes, despite all the drivers using it).

Simple fix would be to move up the assignment of config.funcs to be much earlier in your driver load I guess.
-Daniel

Quoted 22 lines

---

 drivers/gpu/drm/drm_atomic.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/drm_atomic.c +3 -0
index 5eb4013..1729428 100644
@@ -114,6 +114,9 @@ drm_atomic_state_alloc(struct drm_device *dev)
 {
 	struct drm_mode_config *config = &dev->mode_config;
 
+	if (!config->funcs)
+		return NULL;
+
 	if (!config->funcs->atomic_state_alloc) {
 		struct drm_atomic_state *state;
 
Signature · 1 line
2.7.4
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch