linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/atomic: Check that the config funcs exist drm_mode_alloc
@ 2019-05-07 19:14 Jordan Crouse
  2019-05-08  8:35 ` Daniel Vetter
  0 siblings, 1 reply; 2+ messages in thread
From: Jordan Crouse @ 2019-05-07 19:14 UTC (permalink / raw)
  To: freedreno
  Cc: linux-arm-msm, Sean Paul, linux-kernel, dri-devel, David Airlie,
	Maarten Lankhorst, Maxime Ripard, Daniel Vetter

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.

Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
---

 drivers/gpu/drm/drm_atomic.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 5eb4013..1729428 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -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;
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] drm/atomic: Check that the config funcs exist drm_mode_alloc
  2019-05-07 19:14 [PATCH] drm/atomic: Check that the config funcs exist drm_mode_alloc Jordan Crouse
@ 2019-05-08  8:35 ` Daniel Vetter
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Vetter @ 2019-05-08  8:35 UTC (permalink / raw)
  To: Jordan Crouse
  Cc: freedreno, linux-arm-msm, Sean Paul, linux-kernel, dri-devel,
	David Airlie, Maarten Lankhorst, Maxime Ripard, Daniel Vetter

On Tue, May 07, 2019 at 01:14:11PM -0600, Jordan Crouse wrote:
> 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.
> 
> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

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

> ---
> 
>  drivers/gpu/drm/drm_atomic.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> index 5eb4013..1729428 100644
> --- a/drivers/gpu/drm/drm_atomic.c
> +++ b/drivers/gpu/drm/drm_atomic.c
> @@ -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;
>  
> -- 
> 2.7.4
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-05-08  8:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-07 19:14 [PATCH] drm/atomic: Check that the config funcs exist drm_mode_alloc Jordan Crouse
2019-05-08  8:35 ` Daniel Vetter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).