Skip to contentSkip to conversation

drm/exynos: dpi: Fix NULL pointer dereference with legacy bindings

PATCH Applied Tomasz Figa 3 participants 4 messages Jun 10, 2014 – Jun 18, 2014

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

PATCH 1/1 drm/exynos: dpi: Fix NULL pointer dereference with legacy bindings

If there is no panel node in DT and instead display timings are provided directly in FIMD node, there is no panel object created and ctx->panel becomes NULL. However during Exynos DRM initialization drm_helper_hpd_irq_event() is called, which in turns calls exynos_dpi_detect(), which dereferences ctx->panel without a check, causing a NULL pointer derefrence.

This patch fixes the issue by adding necessary NULL pointer check.

---
 drivers/gpu/drm/exynos/exynos_drm_dpi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/exynos/exynos_drm_dpi.c +1 -1
index f1b8587..f44bd90 100644
@@ -40,7 +40,7 @@ exynos_dpi_detect(struct drm_connector *connector, bool force)
 {
 	struct exynos_dpi *ctx = connector_to_dpi(connector);
 
-	if (!ctx->panel->connector)
+	if (ctx->panel && !ctx->panel->connector)
 		drm_panel_attach(ctx->panel, &ctx->connector);
 
 	return connector_status_connected;
Signature · 1 line
2.0.0
#1 lore raw
Quoted 20 lines · Tomasz Figa

If there is no panel node in DT and instead display timings are provided directly in FIMD node, there is no panel object created and ctx->panel becomes NULL. However during Exynos DRM initialization drm_helper_hpd_irq_event() is called, which in turns calls exynos_dpi_detect(), which dereferences ctx->panel without a check, causing a NULL pointer derefrence.

This patch fixes the issue by adding necessary NULL pointer check.

---
 drivers/gpu/drm/exynos/exynos_drm_dpi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/exynos/exynos_drm_dpi.c +0 -0
index f1b8587..f44bd90 100644

drivers/gpu/drm/exynos/exynos_drm_dpi.c exynos_dpi_detect(struct drm_connector *connector, bool force) · line 46

Quoted 8 lines
drivers/gpu/drm/exynos/exynos_drm_dpi.c +1 -1
@@ -40,7 +40,7 @@ exynos_dpi_detect(struct drm_connector *connector, bool force)
 {
 	struct exynos_dpi *ctx = connector_to_dpi(connector);
 
-	if (!ctx->panel->connector)
+	if (ctx->panel && !ctx->panel->connector)
 		drm_panel_attach(ctx->panel, &ctx->connector);
 
 	return connector_status_connected;

Ping.

Best regards,
Tomasz

Reviewed-by on v1 1/1
#3 lore raw
In reply to Tomasz Figa
Quoted 11 lines · Tomasz Figa

If there is no panel node in DT and instead display timings are provided directly in FIMD node, there is no panel object created and ctx->panel becomes NULL. However during Exynos DRM initialization drm_helper_hpd_irq_event() is called, which in turns calls exynos_dpi_detect(), which dereferences ctx->panel without a check, causing a NULL pointer derefrence.

This patch fixes the issue by adding necessary NULL pointer check.

(+cc Inki Dae)

Best regards,
Jingoo Han

Quoted 18 lines
---
 drivers/gpu/drm/exynos/exynos_drm_dpi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/exynos/exynos_drm_dpi.c +1 -2
index f1b8587..f44bd90 100644
@@ -40,7 +40,7 @@ exynos_dpi_detect(struct drm_connector *connector, bool force)
 {
 	struct exynos_dpi *ctx = connector_to_dpi(connector);
 
-	if (!ctx->panel->connector)
+	if (ctx->panel && !ctx->panel->connector)
 		drm_panel_attach(ctx->panel, &ctx->connector);
 
 	return connector_status_connected;
--
maintainer Applied
#2 lore raw
In reply to Tomasz Figa
Quoted 23 lines · Tomasz Figa
Quoted 22 lines · Tomasz Figa

If there is no panel node in DT and instead display timings are provided directly in FIMD node, there is no panel object created and ctx->panel becomes NULL. However during Exynos DRM initialization drm_helper_hpd_irq_event() is called, which in turns calls exynos_dpi_detect(), which dereferences ctx->panel without a check, causing a NULL pointer derefrence.

This patch fixes the issue by adding necessary NULL pointer check.

---
 drivers/gpu/drm/exynos/exynos_drm_dpi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/exynos/exynos_drm_dpi.c +0 -0
index f1b8587..f44bd90 100644
@@ -40,7 +40,7 @@ exynos_dpi_detect(struct drm_connector *connector, bool force)
 {
 	struct exynos_dpi *ctx = connector_to_dpi(connector);
 
Quoted 8 lines

drivers/gpu/drm/exynos/exynos_drm_dpi.c exynos_dpi_detect(struct drm_connector *connector, bool force) · line 46

Quoted 6 lines
drivers/gpu/drm/exynos/exynos_drm_dpi.c +1 -1
-	if (!ctx->panel->connector)
+	if (ctx->panel && !ctx->panel->connector)
 		drm_panel_attach(ctx->panel, &ctx->connector);
 
 	return connector_status_connected;

Ping.

Applied.

Thanks,
Inki Dae

Quoted 8 lines

Best regards,
Tomasz
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html