drm/atomic: track bitmask of planes attached to crtc

Dan Carpenter dan.carpenter at oracle.com
Wed Nov 26 22:41:13 PST 2014


Hello Rob Clark,

The patch 1ed2f34b4cc0: "drm/atomic: track bitmask of planes attached
to crtc" from Nov 21, 2014, leads to the following static checker
warning:

	drivers/gpu/drm/drm_atomic.c:368 drm_atomic_set_crtc_for_plane()
	error: 'plane_state' dereferencing possible ERR_PTR()

drivers/gpu/drm/drm_atomic.c
   360  int
   361  drm_atomic_set_crtc_for_plane(struct drm_atomic_state *state,
   362                                struct drm_plane *plane, struct drm_crtc *crtc)
   363  {
   364          struct drm_plane_state *plane_state =
                                        ^^^^^^^^^^^^^
   365                          drm_atomic_get_plane_state(state, plane);
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
   366          struct drm_crtc_state *crtc_state;
   367  
   368          if (plane_state->crtc) {
                    ^^^^^^^^^^^^^^^^^
Missing IS_ERR() check.

Also drm_atomic_get_plane_state() has poor error handling.  In
drm_atomic_get_plane_state(), if the call to drm_atomic_get_plane_state()
fails then it leaks memory.

   369                  crtc_state = drm_atomic_get_crtc_state(plane_state->state,
   370                                                         plane_state->crtc);
   371                  if (WARN_ON(IS_ERR(crtc_state)))
   372                          return PTR_ERR(crtc_state);
   373  
   374                  crtc_state->plane_mask &= ~(1 << drm_plane_index(plane));
   375          }
   376  
   377          plane_state->crtc = crtc;
   378  

regards,
dan carpenter


More information about the dri-devel mailing list