Skip to contentSkip to conversation

drm/rockchip: dw_hdmi: check IS_ERR() on drm_atomic_get_bridge_state()

PATCH New Elkin Cruz 1 participant 1 message Nov 20

Subsystems (4)
lore
Share & tools
lore

Elkin Cruz

author
#0 lore raw

PATCH 1/1 drm/rockchip: dw_hdmi: check IS_ERR() on drm_atomic_get_bridge_state()

drm_atomic_get_bridge_state() returns an ERR_PTR() on failure rather than NULL. dw_hdmi_rockchip_get_bus_format() checks !bridge_state and then dereferences bridge_state->input_bus_cfg.format, which faults if an error pointer is returned.

Use IS_ERR(bridge_state) instead of !bridge_state.

Fixes dc70272cc184 ("drm/rockchip: dw_hdmi: Propagate bus format to display driver")

---
I am trying out a new Clang static analysis linter for ERR_PTR/NULL handling, and it flagged this code as possibly buggy. The findings were triaged and fixed with an AI coding assistant, then checked against linux-next (not runtime-tested on hardware).

Thanks,
Elkin

 drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c +1 -1
index b6e154c35e7c..30191927593b 100644
@@ -286,7 +286,7 @@ static u32 dw_hdmi_rockchip_get_bus_format(struct drm_encoder *encoder,
 		return 0;
 
 	bridge_state = drm_atomic_get_bridge_state(conn_state->state, bridge);
-	if (!bridge_state)
+	if (IS_ERR(bridge_state))
 		return 0;
 
 	if (bridge_state->input_bus_cfg.format != MEDIA_BUS_FMT_FIXED)
Signature · 1 line
2.56.1.750.gf70dc682cf-goog