Skip to contentSkip to conversation

drm/panel: himax-hx83121a: Fix incorrect error check for devm_drm_panel_alloc()

PATCH Applied Chen Ni 3 participants 3 messages Mar 27 – May 5

Subsystems (3)
lore
Share & tools
lore

Chen Ni

author
#0 lore raw

PATCH 1/1 drm/panel: himax-hx83121a: Fix incorrect error check for devm_drm_panel_alloc()

Check devm_drm_panel_alloc() return value for ERR_PTR instead of NULL. devm_drm_panel_alloc() returns an ERR_PTR on failure, never NULL. Using a NULL check skips the error path and may cause a NULL pointer dereference.

Fixes a7c61963b727 ("drm/panel: Add Himax HX83121A panel driver")
---
 drivers/gpu/drm/panel/panel-himax-hx83121a.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/panel/panel-himax-hx83121a.c +2 -2
index ebe643ba4184..bed79aa06f46 100644
@@ -596,8 +596,8 @@ static int himax_probe(struct mipi_dsi_device *dsi)
 
 	ctx = devm_drm_panel_alloc(dev, struct himax, panel, &himax_panel_funcs,
 				   DRM_MODE_CONNECTOR_DSI);
-	if (!ctx)
-		return -ENOMEM;
+	if (IS_ERR(ctx))
+		return PTR_ERR(ctx);
 
 	ret = devm_regulator_bulk_get_const(&dsi->dev,
 					    ARRAY_SIZE(himax_supplies),
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Chen Ni

Check devm_drm_panel_alloc() return value for ERR_PTR instead of NULL. devm_drm_panel_alloc() returns an ERR_PTR on failure, never NULL. Using a NULL check skips the error path and may cause a NULL pointer dereference.

Fixes a7c61963b727 ("drm/panel: Add Himax HX83121A panel driver")

--
Best wishes,
Pengyu

maintainer Applied
#2 lore raw
In reply to Chen Ni

Hi,

Quoted 4 lines · Chen Ni

Check devm_drm_panel_alloc() return value for ERR_PTR instead of NULL. devm_drm_panel_alloc() returns an ERR_PTR on failure, never NULL. Using a NULL check skips the error path and may cause a NULL pointer dereference.

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

[1/1] drm/panel: himax-hx83121a: Fix incorrect error check for devm_drm_panel_alloc()

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