drm/i915/bios: Move a variable assignment behind a null pointer check in intel_bios_encoder_supports_dp_dual_mode()
PATCH 1/1 drm/i915/bios: Move a variable assignment behind a null pointer check in intel_bios_encoder_supports_dp_dual_mode()
From: Markus Elfring <[email protected]>
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.
--- drivers/gpu/drm/i915/display/intel_bios.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/display/intel_bios.c +2 -2
@@ -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;
Signature · 1 line
2.55.0
Patchwork
CI✗ LGCI.VerificationFailed: failure for drm/i915/bios: Move a variable assignment behind a null pointer check in intel_bios_encoder_supports_dp_dual_mode()
== Series Details ==
== Series Details ==
Series: drm/i915/bios: Move a variable assignment behind a null pointer check in intel_bios_encoder_supports_dp_dual_mode()
URL : https://patchwork.freedesktop.org/series/170414/
State : failure
== Summary ==
Series author address '[email protected]' is not on the allowlist, which prevents CI from being automatically triggered. If you want CI to run for this series, ask Patchwork project owners to click 'retest' on the series in Patchwork. Exception occurred during validation, bailing out!
Build URL: http://intel-gfx-ci-public.igk.intel.com:8080/job/xe_pw_trigger/1215553/ (on master)
Patchwork
CI✗ LGCI.VerificationFailed: failure for drm/i915/bios: Move a variable assignment behind a null pointer check in intel_bios_encoder_supports_dp_dual_mode()
In reply to Markus Elfring== Series Details ==
== Series Details ==
Series: drm/i915/bios: Move a variable assignment behind a null pointer check in intel_bios_encoder_supports_dp_dual_mode()
URL : https://patchwork.freedesktop.org/series/170415/
State : failure
== Summary ==
Series author address '[email protected]' is not on the allowlist, which prevents CI from being automatically triggered. If you want CI to run for this series, ask Patchwork project owners to click 'retest' on the series in Patchwork. Exception occurred during validation, bailing out!
Build URL: http://gfx-ci.igk.intel.com:8080/job/CI_PW_kernel/181358/ (on built-in)
Rodrigo Vivi
maintainerQuoted 33 lines · Markus Elfring
From: Markus Elfring <[email protected]>
Date: Mon, 13 Jul 2026 15:56:46 +0200The 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")Signed-off-by Markus Elfring <[email protected]>--- drivers/gpu/drm/i915/display/intel_bios.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/i915/display/intel_bios.c +0
-2@@ -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;
drivers/gpu/drm/i915/display/intel_bios.c bool intel_bios_encoder_supports_dp_dual_mode(const struct intel_bios_encoder_da · line 3525
Quoted 5 lines
drivers/gpu/drm/i915/display/intel_bios.c +2
-0@@ -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; +
does it compile?
please keep the variable definition where it is and move only its assignment after the null check.
Thanks,
Rodrigo.
Quoted 6 lines
drivers/gpu/drm/i915/display/intel_bios.c +0
-0if (dvo_port_type (child->dvo_port) ==DVO_PORT_DPA )return true;Signature · 1 line
2.55.0
Quoted 8 lines · Rodrigo Vivi
Quoted 7 lines · Markus Elfring
From: Markus Elfring <[email protected]>
Date: Mon, 13 Jul 2026 15:56:46 +0200The 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”.
Quoted 7 lines
Quoted 7 lines
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")
Please stop adding Fixes tags to these and talking about "undefined behavior" in the commit message. Pointer math is defined... It's just a style preference on your part.
regards,
dan carpenter
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
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.
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
This issue was detected by using the Coccinelle software.
Fixes 044cbc7a74c136f12a80c855cadd1b085084aef1 ("drm/i915/bios: Nuke DEVICE_TYPE_DP_DUAL_MODE_BITS")Please stop adding Fixes tags to these and talking about "undefined behavior" in the commit message. Pointer math is defined...
What does hinder you to take additional information sources better into account?
Quoted 1 line
It's just a style preference on your part.
Do you find the guidance appropriate according to the SEI CERT C Coding Standard?
https://cmu-sei.github.io/secure-coding-standards/sei-cert-c-coding-standard/rules/expressions-exp/exp34-c/
Regards,
Markus
Quoted 6 lines
Quoted 6 lines
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.
…
Quoted 14 lines
Quoted 14 lines
+++
b/drivers/gpu/drm/i915/display/intel_bios.cdrivers/gpu/drm/i915/display/intel_bios.c +0
-2@@ -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;
Quoted 7 lines
drivers/gpu/drm/i915/display/intel_bios.c bool intel_bios_encoder_supports_dp_dual_mode(const struct intel_bios_encoder_da · line 3525
Quoted 2 lines
drivers/gpu/drm/i915/display/intel_bios.c +2
-0+const struct child_device_config *child = &devdata->child; +does it compile?
please keep the variable definition where it is and move only its assignment after the null check.
Would you find the proposed adjustment more acceptable if a bit of source code would be moved into another function?
https://refactoring.com/catalog/extractFunction.html
Regards,
Markus