From: Jani Nikula <jani.nikula@linux.intel.com>
To: Suraj Kandpal <suraj.kandpal@intel.com>,
intel-xe@lists.freedesktop.org, intel-gfx@lists.freedesktop.org
Cc: ankit.k.nautiyal@intel.com, Suraj Kandpal <suraj.kandpal@intel.com>
Subject: Re: [PATCH] drm/i915/hdcp: Move dig_port assignment lower in the sequence
Date: Wed, 09 Oct 2024 12:49:46 +0300 [thread overview]
Message-ID: <87y12xa9mt.fsf@intel.com> (raw)
In-Reply-To: <20241009062455.1796615-1-suraj.kandpal@intel.com>
On Wed, 09 Oct 2024, Suraj Kandpal <suraj.kandpal@intel.com> wrote:
> Move dig_port assignment much lower in the sequence to avoid NULL
> pointer deference in case encoder is not present.
Please describe the case exactly. Is this real or a static analyzer
warning?
I see there's commit 6c63e6e14da7 ("drm/i915/hdcp: No HDCP when encoder
is't initialized") adding the !connector->encoder check. But how was
that supposed to fix anything when it leaves
struct intel_digital_port *dig_port = intel_attached_dig_port(connector);
above it in place, the line you're fixing now?
If we haven't seen an oops here, it makes me think the reasoning in
6c63e6e14da7 is bogus, the connector->encoder check is bogus, and this
fix on top is also bogus.
OTOH if we have seen a real issue, we need the backtrace and the
conditions triggering it, and we need to backport this.
While it may seem benign and defensive to add extra NULL checks, one of
the dangers is the cargo culting of those checks. Static analyzers see a
check somewhere, so they complain about unchecked dereferences
everywhere. Checks start cropping up everywhere, and people lose track
of when it's actually possible for the pointers to be NULL, and when
not.
BR,
Jani.
>
> Signed-off-by: Suraj Kandpal <suraj.kandpal@intel.com>
> ---
> drivers/gpu/drm/i915/display/intel_hdcp.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_hdcp.c b/drivers/gpu/drm/i915/display/intel_hdcp.c
> index ed6aa87403e2..ea8d56b25f6e 100644
> --- a/drivers/gpu/drm/i915/display/intel_hdcp.c
> +++ b/drivers/gpu/drm/i915/display/intel_hdcp.c
> @@ -2404,7 +2404,7 @@ static int _intel_hdcp_enable(struct intel_atomic_state *state,
> struct drm_i915_private *i915 = to_i915(display->drm);
> struct intel_connector *connector =
> to_intel_connector(conn_state->connector);
> - struct intel_digital_port *dig_port = intel_attached_dig_port(connector);
> + struct intel_digital_port *dig_port;
> struct intel_hdcp *hdcp = &connector->hdcp;
> unsigned long check_link_interval = DRM_HDCP_CHECK_PERIOD_MS;
> int ret = -EINVAL;
> @@ -2418,6 +2418,8 @@ static int _intel_hdcp_enable(struct intel_atomic_state *state,
> return -ENODEV;
> }
>
> + dig_port = intel_attached_dig_port(connector);
> +
> mutex_lock(&hdcp->mutex);
> mutex_lock(&dig_port->hdcp_mutex);
> drm_WARN_ON(display->drm,
--
Jani Nikula, Intel
next prev parent reply other threads:[~2024-10-09 9:49 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-09 6:24 [PATCH] drm/i915/hdcp: Move dig_port assignment lower in the sequence Suraj Kandpal
2024-10-09 6:51 ` ✓ CI.Patch_applied: success for " Patchwork
2024-10-09 6:51 ` ✓ CI.checkpatch: " Patchwork
2024-10-09 6:52 ` ✓ CI.KUnit: " Patchwork
2024-10-09 7:04 ` ✓ CI.Build: " Patchwork
2024-10-09 7:06 ` ✓ CI.Hooks: " Patchwork
2024-10-09 7:08 ` ✗ CI.checksparse: warning " Patchwork
2024-10-09 7:32 ` ✓ CI.BAT: success " Patchwork
2024-10-09 9:49 ` Jani Nikula [this message]
2024-10-10 4:30 ` [PATCH] " Kandpal, Suraj
2024-10-09 12:08 ` ✗ CI.FULL: failure for " 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=87y12xa9mt.fsf@intel.com \
--to=jani.nikula@linux.intel.com \
--cc=ankit.k.nautiyal@intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=suraj.kandpal@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