]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
drm/amd/display: Reject gpio_bitshift >= 32 in bios_parser_get_gpio_pin_info()
authorHarry Wentland <harry.wentland@amd.com>
Tue, 5 May 2026 15:50:07 +0000 (11:50 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 3 Jun 2026 18:45:02 +0000 (14:45 -0400)
commit49c3da65961fe9857c831d47fa1989084e87514a
tree3dd6381f1dffad1c5efe4b75f53a39bdb840cfe3
parentda48bc4461b8a5ebfb9264c9b191a701d8e99009
drm/amd/display: Reject gpio_bitshift >= 32 in bios_parser_get_gpio_pin_info()

[Why & How]
gpio_bitshift is a uint8_t read directly from the VBIOS GPIO pin table.
If the value is >= 32, the expression "1 << gpio_bitshift" triggers
undefined behaviour in C (shift count exceeds type width). On x86 the
shift is silently masked to 5 bits, producing an incorrect GPIO mask
that may cause wrong MMIO register bits to be toggled.

Validate gpio_bitshift before use and return BP_RESULT_BADBIOSTABLE for
out-of-range values.

Fixes: ae79c310b1a6 ("drm/amd/display: Add DCE12 bios parser support")
Assisted-by: Copilot:claude-opus-4.6
Reviewed-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Ray Wu <ray.wu@amd.com>
Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit eadf438ab8d370b9d19acee9359918c85afeb80d)
Cc: stable@vger.kernel.org
drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c