From a691e3193c9e17f9015e67baee6c0474975396e4 Mon Sep 17 00:00:00 2001 From: jsg Date: Mon, 9 Sep 2024 08:44:25 +0000 Subject: [PATCH] drm/amd/display: Check gpio_id before used as array index From Alex Hung 08e7755f754e3d2cef7d3a7da538d33526bd6f7c in linux-6.6.y/6.6.50 2a5626eeb3b5eec7a36886f9556113dd93ec8ed6 in mainline linux --- sys/dev/pci/drm/amd/display/dc/gpio/gpio_service.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/sys/dev/pci/drm/amd/display/dc/gpio/gpio_service.c b/sys/dev/pci/drm/amd/display/dc/gpio/gpio_service.c index 3ede6e02c3a..2f8ca831afa 100644 --- a/sys/dev/pci/drm/amd/display/dc/gpio/gpio_service.c +++ b/sys/dev/pci/drm/amd/display/dc/gpio/gpio_service.c @@ -239,6 +239,9 @@ static bool is_pin_busy( enum gpio_id id, uint32_t en) { + if (id == GPIO_ID_UNKNOWN) + return false; + return service->busyness[id][en]; } @@ -247,6 +250,9 @@ static void set_pin_busy( enum gpio_id id, uint32_t en) { + if (id == GPIO_ID_UNKNOWN) + return; + service->busyness[id][en] = true; } @@ -255,6 +261,9 @@ static void set_pin_free( enum gpio_id id, uint32_t en) { + if (id == GPIO_ID_UNKNOWN) + return; + service->busyness[id][en] = false; } @@ -263,7 +272,7 @@ enum gpio_result dal_gpio_service_lock( enum gpio_id id, uint32_t en) { - if (!service->busyness[id]) { + if (id != GPIO_ID_UNKNOWN && !service->busyness[id]) { ASSERT_CRITICAL(false); return GPIO_RESULT_OPEN_FAILED; } @@ -277,7 +286,7 @@ enum gpio_result dal_gpio_service_unlock( enum gpio_id id, uint32_t en) { - if (!service->busyness[id]) { + if (id != GPIO_ID_UNKNOWN && !service->busyness[id]) { ASSERT_CRITICAL(false); return GPIO_RESULT_OPEN_FAILED; } -- 2.20.1