dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [bug report] drm/ssd130x: Add support for the SSD132x OLED controller family
@ 2023-10-20 13:54 Dan Carpenter
  2023-10-20 22:42 ` Javier Martinez Canillas
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2023-10-20 13:54 UTC (permalink / raw)
  To: javierm; +Cc: dri-devel

Hello Javier Martinez Canillas,

The patch fdd591e00a9c: "drm/ssd130x: Add support for the SSD132x
OLED controller family" from Oct 14, 2023 (linux-next), leads to the
following Smatch static checker warning:

	drivers/gpu/drm/solomon/ssd130x.c:921 ssd132x_primary_plane_atomic_check()
	error: uninitialized symbol 'crtc_state'.

drivers/gpu/drm/solomon/ssd130x.c
    905 static int ssd132x_primary_plane_atomic_check(struct drm_plane *plane,
    906                                               struct drm_atomic_state *state)
    907 {
    908         struct drm_device *drm = plane->dev;
    909         struct ssd130x_device *ssd130x = drm_to_ssd130x(drm);
    910         struct drm_plane_state *plane_state = drm_atomic_get_new_plane_state(state, plane);
    911         struct ssd130x_plane_state *ssd130x_state = to_ssd130x_plane_state(plane_state);
    912         struct drm_crtc *crtc = plane_state->crtc;
    913         struct drm_crtc_state *crtc_state;
    914         const struct drm_format_info *fi;
    915         unsigned int pitch;
    916         int ret;
    917 
    918         if (crtc)
    919                 crtc_state = drm_atomic_get_new_crtc_state(state, crtc);

crtc_state is not initialized

    920 
--> 921         ret = drm_atomic_helper_check_plane_state(plane_state, crtc_state,

The rule here is that if drm_atomic_helper_check_plane_state() is
inlined then we have to examine it to see if "crtc_state" is used, but
since it's not inlined then passing uninitialized data is a bug
regardless of whether or not it's used.  It will triger a KMsan warning
at runtime as well.

    922                                                   DRM_PLANE_NO_SCALING,
    923                                                   DRM_PLANE_NO_SCALING,
    924                                                   false, false);
    925         if (ret)
    926                 return ret;
    927         else if (!plane_state->visible)
    928                 return 0;
    929 
    930         fi = drm_format_info(DRM_FORMAT_R8);
    931         if (!fi)

regards,
dan carpenter

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

* Re: [bug report] drm/ssd130x: Add support for the SSD132x OLED controller family
  2023-10-20 13:54 [bug report] drm/ssd130x: Add support for the SSD132x OLED controller family Dan Carpenter
@ 2023-10-20 22:42 ` Javier Martinez Canillas
  0 siblings, 0 replies; 2+ messages in thread
From: Javier Martinez Canillas @ 2023-10-20 22:42 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: dri-devel

Dan Carpenter <dan.carpenter@linaro.org> writes:

Hello Dan,

> Hello Javier Martinez Canillas,
>
> The patch fdd591e00a9c: "drm/ssd130x: Add support for the SSD132x
> OLED controller family" from Oct 14, 2023 (linux-next), leads to the
> following Smatch static checker warning:
>
> 	drivers/gpu/drm/solomon/ssd130x.c:921 ssd132x_primary_plane_atomic_check()
> 	error: uninitialized symbol 'crtc_state'.
>
> drivers/gpu/drm/solomon/ssd130x.c
>     905 static int ssd132x_primary_plane_atomic_check(struct drm_plane *plane,
>     906                                               struct drm_atomic_state *state)
>     907 {
>     908         struct drm_device *drm = plane->dev;
>     909         struct ssd130x_device *ssd130x = drm_to_ssd130x(drm);
>     910         struct drm_plane_state *plane_state = drm_atomic_get_new_plane_state(state, plane);
>     911         struct ssd130x_plane_state *ssd130x_state = to_ssd130x_plane_state(plane_state);
>     912         struct drm_crtc *crtc = plane_state->crtc;
>     913         struct drm_crtc_state *crtc_state;
>     914         const struct drm_format_info *fi;
>     915         unsigned int pitch;
>     916         int ret;
>     917 
>     918         if (crtc)
>     919                 crtc_state = drm_atomic_get_new_crtc_state(state, crtc);
>
> crtc_state is not initialized
>

Indeed. Thanks a lot for reporting this.

I'll post a fix.

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


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

end of thread, other threads:[~2023-10-20 22:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-20 13:54 [bug report] drm/ssd130x: Add support for the SSD132x OLED controller family Dan Carpenter
2023-10-20 22:42 ` Javier Martinez Canillas

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