Re: drm/atomic: track bitmask of planes attached to crtc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Nov 27, 2014 at 09:41:13AM +0300, Dan Carpenter wrote:
> 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()

Hm yeah that shouldn't ever happen when callers use this correctly. But a
WARN_ON would be good I guess. I'll add it.

> 
> 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.

Where does it leak memory exactly?
> 
>    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
> _______________________________________________
> dri-devel mailing list
> dri-devel@xxxxxxxxxxxxxxxxxxxxx
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/dri-devel





[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux