Skip to contentSkip to conversation

drm/amd/display: Check hpd_gpio for NULL before accessing it

PATCH In review Harry Wentland 2 participants 3 messages Feb 7, 2019 2 messages not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amd/display: Check hpd_gpio for NULL before accessing it

dal_gpio_open and dal_gpio_unlock_pin dereference hpd_gpio. Check for NULL before calling those functions.

Fixes e261568f94d6 ("drm/amd/display: add gpio lock/unlock")
CC Chiawen Huang <[email protected]>
CC Tony Cheng <[email protected]>

---

I don't have a system to test this on. Can someone give it a spin?

Harry

 drivers/gpu/drm/amd/display/dc/core/dc_link.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/display/dc/core/dc_link.c +4 -3
index 6d2cef05b4d7..7f5a947ad31d 100644
@@ -1127,10 +1127,11 @@ static bool construct(
 		link->dc->res_pool->funcs->link_init(link);
 
 	link->hpd_gpio = get_hpd_gpio(link->ctx->dc_bios, link->link_id, link->ctx->gpio_service);
-	dal_gpio_open(link->hpd_gpio, GPIO_MODE_INTERRUPT);
-	dal_gpio_unlock_pin(link->hpd_gpio);
-	if (link->hpd_gpio != NULL)
+	if (link->hpd_gpio != NULL) {
+		dal_gpio_open(link->hpd_gpio, GPIO_MODE_INTERRUPT);
+		dal_gpio_unlock_pin(link->hpd_gpio);
 		link->irq_source_hpd = dal_irq_get_source(link->hpd_gpio);
+	}
 
 	switch (link->link_id.id) {
 	case CONNECTOR_ID_HDMI_TYPE_A:
Signature · 6 lines
2.19.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 20190207201235.30106-1-harry.wentland-5C7GfCeVMHo@public.gmane.org

Acked-by
#2 lore raw
Quoted 9 lines · Harry Wentland

dal_gpio_open and dal_gpio_unlock_pin dereference hpd_gpio. Check for NULL before calling those functions.

Fixes e261568f94d6 ("drm/amd/display: add gpio lock/unlock")
CC Chiawen Huang <[email protected]>
CC Tony Cheng <[email protected]>
Quoted 29 lines

---

I don't have a system to test this on. Can someone give it a spin?

Harry

 drivers/gpu/drm/amd/display/dc/core/dc_link.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/display/dc/core/dc_link.c +4 -4
index 6d2cef05b4d7..7f5a947ad31d 100644
@@ -1127,10 +1127,11 @@ static bool construct(
                link->dc->res_pool->funcs->link_init(link);
 
        link->hpd_gpio = get_hpd_gpio(link->ctx->dc_bios, link->link_id, link->ctx->gpio_service);
-       dal_gpio_open(link->hpd_gpio, GPIO_MODE_INTERRUPT);
-       dal_gpio_unlock_pin(link->hpd_gpio);
-       if (link->hpd_gpio != NULL)
+       if (link->hpd_gpio != NULL) {
+               dal_gpio_open(link->hpd_gpio, GPIO_MODE_INTERRUPT);
+               dal_gpio_unlock_pin(link->hpd_gpio);
                link->irq_source_hpd = dal_irq_get_source(link->hpd_gpio);
+       }
 
        switch (link->link_id.id) {
        case CONNECTOR_ID_HDMI_TYPE_A:
--
Quoted 2 lines

2.19.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): CADnq5_OQQpvrrvrCYOGKgo_YtdT8gPwuMzLgWKAtwAoZmp-4Vg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

Tested-by
#4 lore raw
Quoted 6 lines · Alex Deucher
Quoted 4 lines · Harry Wentland

dal_gpio_open and dal_gpio_unlock_pin dereference hpd_gpio. Check for NULL before calling those functions.

Quoted 8 lines
Quoted 5 lines
Fixes e261568f94d6 ("drm/amd/display: add gpio lock/unlock")
CC Chiawen Huang <[email protected]>
CC Tony Cheng <[email protected]>

Just tried it on a bonaire.

Quoted 26 lines
Quoted 26 lines

---

I don't have a system to test this on. Can someone give it a spin?

Harry

 drivers/gpu/drm/amd/display/dc/core/dc_link.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/display/dc/core/dc_link.c +4 -3
index 6d2cef05b4d7..7f5a947ad31d 100644
@@ -1127,10 +1127,11 @@ static bool construct(
                link->dc->res_pool->funcs->link_init(link);
 
        link->hpd_gpio = get_hpd_gpio(link->ctx->dc_bios, link->link_id, link->ctx->gpio_service);
-       dal_gpio_open(link->hpd_gpio, GPIO_MODE_INTERRUPT);
-       dal_gpio_unlock_pin(link->hpd_gpio);
-       if (link->hpd_gpio != NULL)
+       if (link->hpd_gpio != NULL) {
+               dal_gpio_open(link->hpd_gpio, GPIO_MODE_INTERRUPT);
+               dal_gpio_unlock_pin(link->hpd_gpio);
                link->irq_source_hpd = dal_irq_get_source(link->hpd_gpio);
+       }
 
Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/amd/display/dc/core/dc_link.c +0 -1
        switch (link->link_id.id) {
        case CONNECTOR_ID_HDMI_TYPE_A:
--

2.19.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx