From: Jonathan Cavitt <jonathan.cavitt@intel.com>
To: intel-gfx@lists.freedesktop.org
Cc: saurabhg.gupta@intel.com, alex.zuo@intel.com, jonathan.cavitt@intel.com
Subject: [PATCH] drm/i915/display: Fail intel_ddi_init if encoder init fails
Date: Wed, 28 Jan 2026 20:56:30 +0000 [thread overview]
Message-ID: <20260128205629.66618-2-jonathan.cavitt@intel.com> (raw)
Static analysis issue:
drm_encoder_init is capable of returning an error code in some cases,
such as when drm_mode_object_add fails, or if
dev->mode_config.num_encoder >= 32. In these cases, encoder->dev is not
properly initialized, which may lead to issues when it is dereferenced
in, for example, intel_ddi_init_dp_connector, which calls
intel_dp_init_connector.
Much like the other error cases in this function, just return if an
error code is reported from drm_encoder_init. Note that goto err in
this case would only exacerbate the issue, as drm_encoder_cleanup also
relies on encoder->dev being present. So, just kfree the dig_port
before returning, as that's the only necessary part of the error path to
call here.
Signed-off-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
---
drivers/gpu/drm/i915/display/intel_ddi.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/i915/display/intel_ddi.c b/drivers/gpu/drm/i915/display/intel_ddi.c
index d8739e2bb004..7fc5f726e9a8 100644
--- a/drivers/gpu/drm/i915/display/intel_ddi.c
+++ b/drivers/gpu/drm/i915/display/intel_ddi.c
@@ -5264,9 +5264,12 @@ void intel_ddi_init(struct intel_display *display,
encoder = &dig_port->base;
encoder->devdata = devdata;
- drm_encoder_init(display->drm, &encoder->base, &intel_ddi_funcs,
- DRM_MODE_ENCODER_TMDS, "%s",
- intel_ddi_encoder_name(display, port, phy, &encoder_name));
+ if (drm_encoder_init(display->drm, &encoder->base, &intel_ddi_funcs,
+ DRM_MODE_ENCODER_TMDS, "%s",
+ intel_ddi_encoder_name(display, port, phy, &encoder_name))) {
+ kfree(dig_port);
+ return;
+ }
intel_encoder_link_check_init(encoder, intel_ddi_link_check);
--
2.43.0
next reply other threads:[~2026-01-28 20:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-28 20:56 Jonathan Cavitt [this message]
2026-01-28 21:49 ` ✗ i915.CI.BAT: failure for drm/i915/display: Fail intel_ddi_init if encoder init fails Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260128205629.66618-2-jonathan.cavitt@intel.com \
--to=jonathan.cavitt@intel.com \
--cc=alex.zuo@intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=saurabhg.gupta@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox