linux-stable/drivers/gpu/drm/sti
Ville Syrjälä 442cf8e22b drm/sti: Use drm_mode_copy()
struct drm_display_mode embeds a list head, so overwriting
the full struct with another one will corrupt the list
(if the destination mode is on a list). Use drm_mode_copy()
instead which explicitly preserves the list head of
the destination mode.

Even if we know the destination mode is not on any list
using drm_mode_copy() seems decent as it sets a good
example. Bad examples of not using it might eventually
get copied into code where preserving the list head
actually matters.

Obviously one case not covered here is when the mode
itself is embedded in a larger structure and the whole
structure is copied. But if we are careful when copying
into modes embedded in structures I think we can be a
little more reassured that bogus list heads haven't been
propagated in.

@is_mode_copy@
@@
drm_mode_copy(...)
{
...
}

@depends on !is_mode_copy@
struct drm_display_mode *mode;
expression E, S;
@@
(
- *mode = E
+ drm_mode_copy(mode, &E)
|
- memcpy(mode, E, S)
+ drm_mode_copy(mode, E)
)

@depends on !is_mode_copy@
struct drm_display_mode mode;
expression E;
@@
(
- mode = E
+ drm_mode_copy(&mode, &E)
|
- memcpy(&mode, E, S)
+ drm_mode_copy(&mode, E)
)

@@
struct drm_display_mode *mode;
@@
- &*mode
+ mode

Cc: Alain Volmat <alain.volmat@foss.st.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20221107192545.9896-8-ville.syrjala@linux.intel.com
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2022-11-12 01:41:35 +02:00
..
Kconfig drm/gem: rename GEM CMA helpers to GEM DMA helpers 2022-08-03 18:31:49 +02:00
Makefile
NOTES
sti_awg_utils.c
sti_awg_utils.h
sti_compositor.c drm: Remove linux/fb.h from drm_crtc.h 2022-07-05 21:14:02 +03:00
sti_compositor.h
sti_crtc.c drm: Remove unnecessary include statements of drm_plane_helper.h 2022-07-26 18:42:04 +02:00
sti_crtc.h
sti_cursor.c drm/gem: rename GEM CMA helpers to GEM DMA helpers 2022-08-03 18:31:49 +02:00
sti_cursor.h
sti_drv.c drm/fb-helper: Move generic fbdev emulation into separate source file 2022-11-05 17:12:04 +01:00
sti_drv.h
sti_dvo.c drm/sti: Use drm_mode_copy() 2022-11-12 01:41:35 +02:00
sti_gdp.c drm/gem: rename struct drm_gem_dma_object.{paddr => dma_addr} 2022-08-03 18:32:27 +02:00
sti_gdp.h
sti_hda.c drm/sti: Use drm_mode_copy() 2022-11-12 01:41:35 +02:00
sti_hdmi.c drm/sti: Use drm_mode_copy() 2022-11-12 01:41:35 +02:00
sti_hdmi.h
sti_hdmi_tx3g4c28phy.c
sti_hdmi_tx3g4c28phy.h
sti_hqvdp.c drm/gem: rename struct drm_gem_dma_object.{paddr => dma_addr} 2022-08-03 18:32:27 +02:00
sti_hqvdp_lut.h
sti_mixer.c
sti_mixer.h
sti_plane.c drm/gem: rename GEM CMA helpers to GEM DMA helpers 2022-08-03 18:31:49 +02:00
sti_plane.h drm: Remove unnecessary include statements of drm_plane_helper.h 2022-07-26 18:42:04 +02:00
sti_tvout.c
sti_vid.c
sti_vid.h
sti_vtg.c
sti_vtg.h