Skip to contentSkip to conversation

drm/panel: Fix a possible null-pointer dereference in jdi_panel_dsi_remove()

PATCH Applied Tuo Li 2 participants 3 messages Dec 18, 2025 – Jan 13

Subsystems (3)
lore
Share & tools
lore

Tuo Li

author
#0 lore raw

PATCH 1/1 drm/panel: Fix a possible null-pointer dereference in jdi_panel_dsi_remove()

In jdi_panel_dsi_remove(), jdi is explicitly checked, indicating that it may be NULL:

  if (!jdi)
    mipi_dsi_detach(dsi);

However, when jdi is NULL, the function does not return and continues by calling jdi_panel_disable():

  err = jdi_panel_disable(&jdi->base);

Inside jdi_panel_disable(), jdi is dereferenced unconditionally, which can lead to a NULL-pointer dereference:

  struct jdi_panel *jdi = to_panel_jdi(panel);
  backlight_disable(jdi->backlight);

To prevent such a potential NULL-pointer dereference, return early from jdi_panel_dsi_remove() when jdi is NULL.

---
 drivers/gpu/drm/panel/panel-jdi-lpm102a188a.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/panel/panel-jdi-lpm102a188a.c +3 -1
index 23462065d726..ea975170faff 100644
@@ -434,8 +434,10 @@ static void jdi_panel_dsi_remove(struct mipi_dsi_device *dsi)
 	int err;
 
 	/* only detach from host for the DSI-LINK2 interface */
-	if (!jdi)
+	if (!jdi) {
 		mipi_dsi_detach(dsi);
+		return;
+	}
 
 	err = jdi_panel_disable(&jdi->base);
 	if (err < 0)
Signature · 1 line
2.43.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 31 lines · Tuo Li

In jdi_panel_dsi_remove(), jdi is explicitly checked, indicating that it may be NULL:

   if (!jdi)
     mipi_dsi_detach(dsi);

However, when jdi is NULL, the function does not return and continues by calling jdi_panel_disable():

   err = jdi_panel_disable(&jdi->base);

Inside jdi_panel_disable(), jdi is dereferenced unconditionally, which can lead to a NULL-pointer dereference:

   struct jdi_panel *jdi = to_panel_jdi(panel);
   backlight_disable(jdi->backlight);

To prevent such a potential NULL-pointer dereference, return early from jdi_panel_dsi_remove() when jdi is NULL.

---
  drivers/gpu/drm/panel/panel-jdi-lpm102a188a.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/panel/panel-jdi-lpm102a188a.c +0 -0
index 23462065d726..ea975170faff 100644
@@ -434,8 +434,10 @@ static void jdi_panel_dsi_remove(struct mipi_dsi_device *dsi)
  	int err;

drivers/gpu/drm/panel/panel-jdi-lpm102a188a.c static void jdi_panel_dsi_remove(struct mipi_dsi_device *dsi) · line 443

Quoted 10 lines
drivers/gpu/drm/panel/panel-jdi-lpm102a188a.c +3 -1
 
  	/* only detach from host for the DSI-LINK2 interface */
-	if (!jdi)
+	if (!jdi) {
  		mipi_dsi_detach(dsi);
+		return;
+	}
 
  	err = jdi_panel_disable(&jdi->base);
  	if (err < 0)

Thanks,
Neil

maintainer Applied
#2 lore raw
In reply to Tuo Li

Hi,

Quoted 10 lines · Tuo Li

In jdi_panel_dsi_remove(), jdi is explicitly checked, indicating that it may be NULL:

  if (!jdi)
    mipi_dsi_detach(dsi);

However, when jdi is NULL, the function does not return and continues by calling jdi_panel_disable():

[...]

Thanks, Applied to https://gitlab.freedesktop.org/drm/misc/kernel.git (drm-misc-next)

[1/1] drm/panel: Fix a possible null-pointer dereference in jdi_panel_dsi_remove()

      https://gitlab.freedesktop.org/drm/misc/kernel/-/commit/95eed73b871111123a8b1d31cb1fce7e902e49ea
Signature · 1 line
Neil