Skip to content

Commit c206a27

Browse files
lucacoelhomkahola
authored andcommitted
drm/i915/dkl: return if tc_port is invalid in dkl_phy_set_hip_idx()
In dkl_phy_set_hip_idx(), we may try to shift a value negatively, whose behavior is undefined. This can happen because we define TC_PORT_NONE to -1, so theoretically tc_port could be -1. We will then use tc_port to shift to the correct address of the specified port, but if it's negative, anything can happen. If this happens or tc_port exceeds I915_MAX_TC_PORTS, it's safer to return with a warning than risk an invalid write. Signed-off-by: Luca Coelho <luciano.coelho@intel.com> Reviewed-by: Mika Kahola <mika.kahola@intel.com> Signed-off-by: Mika Kahola <mika.kahola@intel.com> Link: https://lore.kernel.org/r/20250520082917.1302665-2-luciano.coelho@intel.com
1 parent e117100 commit c206a27

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

drivers/gpu/drm/i915/display/intel_dkl_phy.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ dkl_phy_set_hip_idx(struct intel_display *display, struct intel_dkl_phy_reg reg)
2525
{
2626
enum tc_port tc_port = DKL_REG_TC_PORT(reg);
2727

28-
drm_WARN_ON(display->drm, tc_port < TC_PORT_1 || tc_port >= I915_MAX_TC_PORTS);
28+
if (drm_WARN_ON(display->drm,
29+
tc_port < TC_PORT_1 || tc_port >= I915_MAX_TC_PORTS))
30+
return;
2931

3032
intel_de_write(display,
3133
HIP_INDEX_REG(tc_port),

0 commit comments

Comments
 (0)