bianbu-linux-6.6/drivers/gpu/drm/rockchip
Ville Syrjälä 2bfaa28000 drm/rockchip: 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

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>
2022-11-12 01:41:35 +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-11-12 01:41:35 +02: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 drm/rockchip: cdn-dp: fix sign extension on an int multiply for a u64 result 2021-05-28 20:27:44 +02:00
cdn-dp-reg.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 282 2019-06-05 17:36:37 +02:00
dw-mipi-dsi-rockchip.c drm/rockchip: use pm_runtime_resume_and_get() instead of pm_runtime_get_sync() 2022-10-29 23:48:46 +02:00
dw_hdmi-rockchip.c drm/rockchip: dw_hdmi: add regulator support 2022-05-03 12:56:05 +02:00
inno_hdmi.c drm/rockchip: Use drm_mode_copy() 2022-11-12 01:41:35 +02:00
inno_hdmi.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 282 2019-06-05 17:36:37 +02: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
rk3066_hdmi.c drm/rockchip: Use drm_mode_copy() 2022-11-12 01:41:35 +02:00
rk3066_hdmi.h
rockchip_drm_drv.c drm/fb-helper: Move generic fbdev emulation into separate source file 2022-11-05 17:12:04 +01:00
rockchip_drm_drv.h drm/fb-helper: Remove unnecessary include statements 2022-11-05 17:12:04 +01:00
rockchip_drm_fb.c drm/rockchip: Don't set struct drm_driver.output_poll_changed 2022-11-05 17:05:53 +01:00
rockchip_drm_fb.h drm: rockchip: remove rockchip_drm_framebuffer_init() function 2022-10-29 18:31:09 +02:00
rockchip_drm_gem.c drm/fb-helper: Remove unnecessary include statements 2022-11-05 17:12:04 +01: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-10-29 23:48:46 +02: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-10-29 23:48:46 +02: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-10-29 23:55:41 +02:00
rockchip_lvds.h drm/rockchip: lvds: Add PX30 support 2020-01-06 11:56:02 +01:00
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: vop2: Register Esmart0-win0 as primary plane 2022-10-29 18:34:51 +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