[PATCH] drm/i915/bios: Move a variable assignment behind a null pointer check in intel_bios_encoder_supports_dp_dual_mode()

From: Markus Elfring

Date: Mon Jul 13 2026 - 10:15:52 EST


From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 13 Jul 2026 15:56:46 +0200

The address of a data structure member was determined before
a corresponding null pointer check in the implementation of
the function “intel_bios_encoder_supports_dp_dual_mode”.

Thus avoid the risk for undefined behaviour by reducing the scope for
the variable “child” behind condition checks.

This issue was detected by using the Coccinelle software.

Fixes: 044cbc7a74c136f12a80c855cadd1b085084aef1 ("drm/i915/bios: Nuke DEVICE_TYPE_DP_DUAL_MODE_BITS")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
---
drivers/gpu/drm/i915/display/intel_bios.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_bios.c b/drivers/gpu/drm/i915/display/intel_bios.c
index 97cbae2e547e..1c4760373514 100644
--- a/drivers/gpu/drm/i915/display/intel_bios.c
+++ b/drivers/gpu/drm/i915/display/intel_bios.c
@@ -3514,8 +3514,6 @@ bool intel_bios_is_port_present(struct intel_display *display, enum port port)

bool intel_bios_encoder_supports_dp_dual_mode(const struct intel_bios_encoder_data *devdata)
{
- const struct child_device_config *child = &devdata->child;
-
if (!devdata)
return false;

@@ -3523,6 +3521,8 @@ bool intel_bios_encoder_supports_dp_dual_mode(const struct intel_bios_encoder_da
!intel_bios_encoder_supports_hdmi(devdata))
return false;

+ const struct child_device_config *child = &devdata->child;
+
if (dvo_port_type(child->dvo_port) == DVO_PORT_DPA)
return true;

--
2.55.0