mirror-linux/drivers/gpu/drm/rockchip
Ville Syrjälä e398c0ad0c drm/rockchip: Use drm_mode_copy()
[ Upstream commit 2bfaa28000 ]

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

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Sandy Huang <hjc@rock-chips.com>
Cc: "Heiko Stübner" <heiko@sntech.de>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-rockchip@lists.infradead.org
Link: https://patchwork.freedesktop.org/patch/msgid/20221107192545.9896-7-ville.syrjala@linux.intel.com
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-12-31 13:33:01 +01:00
..
Kconfig drm/gem: rename GEM CMA helpers to GEM DMA helpers 2022-08-03 18:31:49 +02:00
Makefile drm/rockchip: Add VOP2 driver 2022-05-04 14:05:47 +02:00
analogix_dp-rockchip.c drm/rockchip: Fix an error handling path rockchip_dp_probe() 2022-07-02 13:03:12 +02:00
cdn-dp-core.c drm/rockchip: Use drm_mode_copy() 2022-12-31 13:33:01 +01:00
cdn-dp-core.h drm/rockchip: Embed drm_encoder into rockchip_decoder 2022-05-03 11:23:47 +02:00
cdn-dp-reg.c
cdn-dp-reg.h
dw-mipi-dsi-rockchip.c drm/rockchip: use pm_runtime_resume_and_get() instead of pm_runtime_get_sync() 2022-12-31 13:32:59 +01:00
dw_hdmi-rockchip.c drm/rockchip: dw_hdmi: filter regulator -EPROBE_DEFER error messages 2022-10-29 14:40:10 +02:00
inno_hdmi.c drm/rockchip: Use drm_mode_copy() 2022-12-31 13:33:01 +01:00
inno_hdmi.h
rk3066_hdmi.c drm/rockchip: Use drm_mode_copy() 2022-12-31 13:33:01 +01:00
rk3066_hdmi.h
rockchip_drm_drv.c drm-misc-next for v6.1: 2022-09-06 10:56:04 +02:00
rockchip_drm_drv.h drm/rockchip: Add VOP2 driver 2022-05-04 14:05:47 +02:00
rockchip_drm_fb.c drm: Drop drm_framebuffer.h from drm_crtc.h 2022-06-20 23:53:55 +03:00
rockchip_drm_fb.h
rockchip_drm_gem.c drm/rockchip: fix fbdev on non-IOMMU devices 2022-10-29 14:40:53 +02:00
rockchip_drm_gem.h dma-buf-map: Rename to iosys-map 2022-02-07 16:35:35 -08:00
rockchip_drm_vop.c drm/rockchip: use pm_runtime_resume_and_get() instead of pm_runtime_get_sync() 2022-12-31 13:32:59 +01:00
rockchip_drm_vop.h drm/rockchip: define gamma registers for RK3399 2022-09-15 15:09:10 +02:00
rockchip_drm_vop2.c drm/rockchip: use pm_runtime_resume_and_get() instead of pm_runtime_get_sync() 2022-12-31 13:32:59 +01:00
rockchip_drm_vop2.h drm/rockchip: Add VOP2 driver 2022-05-04 14:05:47 +02:00
rockchip_lvds.c drm/rockchip: lvds: fix PM usage counter unbalance in poweron 2022-12-31 13:32:06 +01:00
rockchip_lvds.h
rockchip_rgb.c drm: Remove linux/media-bus-format.h from drm_crtc.h 2022-07-05 21:15:13 +03:00
rockchip_rgb.h
rockchip_vop2_reg.c drm/rockchip: Add VOP2 driver 2022-05-04 14:05:47 +02:00
rockchip_vop_reg.c drm/rockchip: define gamma registers for RK3399 2022-09-15 15:09:10 +02:00
rockchip_vop_reg.h drm/rockchip: define gamma registers for RK3399 2022-09-15 15:09:10 +02:00