OSDN Git Service

drm/amdgpu: Use drm_mode_init() for on-stack modes
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Mon, 7 Nov 2022 19:25:39 +0000 (21:25 +0200)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 10 Nov 2022 20:29:56 +0000 (15:29 -0500)
commit0a204ce0e698e5b94a064de6848b8c4641860f64
treeff5b6a6efbd812288bbb48290a5c941a50980e62
parentecc9b6e15af2ffc8b9c0e6f15160eb8aaea36af5
drm/amdgpu: Use drm_mode_init() for on-stack modes

Initialize on-stack modes with drm_mode_init() to guarantee
no stack garbage in the list head, or that we aren't copying
over another mode's list head.

Based on the following cocci script, with manual fixups:
@decl@
identifier M;
expression E;
@@
- struct drm_display_mode M = E;
+ struct drm_display_mode M;

@@
identifier decl.M;
expression decl.E;
statement S, S1;
@@
struct drm_display_mode M;
... when != S
+ drm_mode_init(&M, &E);
+
S1

@@
expression decl.E;
@@
- &*E
+ E

Cc: Harry Wentland <harry.wentland@amd.com>
Cc: Leo Li <sunpeng.li@amd.com>
Cc: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: amd-gfx@lists.freedesktop.org
Reviewed-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c