summaryrefslogtreecommitdiff
path: root/sys/dev/pci
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2024-09-09 08:44:26 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2024-09-09 08:44:26 +0000
commit22262e84c620f6a4758c77f9b9ab35f606e8b7c4 (patch)
tree65374725b66ac10880cee5efdb0f598406c578f4 /sys/dev/pci
parent74fba477c16a9b35a01dfffab99e024f9551b39d (diff)
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
Diffstat (limited to 'sys/dev/pci')
-rw-r--r--sys/dev/pci/drm/amd/display/dc/gpio/gpio_service.c13
1 files 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;
}