1
0
Fork 0
mirror of synced 2025-03-06 20:59:54 +01:00
linux/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 License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
NOTES
sti_awg_utils.c drm/sti: drop use of drmP.h 2019-06-06 17:11:26 +02:00
sti_awg_utils.h drm/sti: drop use of drmP.h 2019-06-06 17:11:26 +02:00
sti_compositor.c drm: Remove linux/fb.h from drm_crtc.h 2022-07-05 21:14:02 +03:00
sti_compositor.h drm/sti: remove use of drm_debugfs functions as return values 2020-03-18 16:24:08 +01:00
sti_crtc.c drm: Remove unnecessary include statements of drm_plane_helper.h 2022-07-26 18:42:04 +02:00
sti_crtc.h drm/sti: Convert to CRTC VBLANK callbacks 2020-02-13 13:10:09 +01:00
sti_cursor.c drm/gem: rename GEM CMA helpers to GEM DMA helpers 2022-08-03 18:31:49 +02:00
sti_cursor.h drm/sti: drop use of drmP.h 2019-06-06 17:11:26 +02:00
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 drm/sti: drop use of drmP.h 2019-06-06 17:11:26 +02:00
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 drm/sti: drop use of drmP.h 2019-06-06 17:11:26 +02:00
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 drm/sti/sti_hdmi: Move 'colorspace_mode_names' array to where its used 2020-11-12 20:32:53 +01:00
sti_hdmi_tx3g4c28phy.c drm/sti/sti_hdmi_tx3g4c28phy: Provide function names for kernel-doc headers 2021-06-03 13:29:11 +02:00
sti_hdmi_tx3g4c28phy.h gpu: drm: sti: Adopt SPDX identifiers 2017-12-06 15:51:23 +01:00
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 gpu: drm: sti: Adopt SPDX identifiers 2017-12-06 15:51:23 +01:00
sti_mixer.c drm/sti: remove use of drm_debugfs functions as return values 2020-03-18 16:24:08 +01:00
sti_mixer.h drm/sti: remove use of drm_debugfs functions as return values 2020-03-18 16:24:08 +01:00
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 drm/sti/sti_tvout: Provide a bunch of missing function names 2021-06-03 13:29:26 +02:00
sti_vid.c drm/sti: remove use of drm_debugfs functions as return values 2020-03-18 16:24:08 +01:00
sti_vid.h drm/sti: remove use of drm_debugfs functions as return values 2020-03-18 16:24:08 +01:00
sti_vtg.c remove ioremap_nocache and devm_ioremap_nocache 2020-01-06 09:45:59 +01:00
sti_vtg.h drm/sti: drop use of drmP.h 2019-06-06 17:11:26 +02:00