public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@linux.intel.com>
To: Wentao Liang <vulab@iscas.ac.cn>,
	thierry.reding@gmail.com, mperttunen@nvidia.com,
	airlied@gmail.com, simona@ffwll.ch, jonathanh@nvidia.com
Cc: dri-devel@lists.freedesktop.org, linux-tegra@vger.kernel.org,
	linux-kernel@vger.kernel.org, Wentao Liang <vulab@iscas.ac.cn>,
	stable@vger.kernel.org
Subject: Re: [PATCH] drm/tegra: Handle EDID allocation failures in tegra_output_connector_get_modes()
Date: Wed, 05 Mar 2025 19:17:15 +0200	[thread overview]
Message-ID: <874j07xuqs.fsf@intel.com> (raw)
In-Reply-To: <20250305154038.2062-1-vulab@iscas.ac.cn>

On Wed, 05 Mar 2025, Wentao Liang <vulab@iscas.ac.cn> wrote:
> The return values of `drm_edid_dup()` and `drm_edid_read_ddc()` must
> be checked in `tegra_output_connector_get_modes()` to prevent NULL
> pointer dereferences. If either function fails, the function should
> immediately return 0, indicating that no display modes can be retrieved.

No. It works as designed, and drm_edid_connector_update() and
cec_notifier_set_phys_addr() *must* be called with NULL drm_edid in case
of failure.

> A proper implementation can be found in `vidi_get_modes()`, where the
> return values are carefully validated, and the function returns 0 upon
> failure.

That case is slightly different, as it doesn't actually access the
display at that point, but it wouldn't be wrong to skip the early
!drm_edid check there too.

> Fixes: 98365ca74cbf ("drm/tegra: convert to struct drm_edid")

When you claim to fix a commit, it's encouraged to Cc: the author and
possibly reviewers of said commit.


BR,
Jani.


> Cc: stable@vger.kernel.org # 6.12+
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
> ---
>  drivers/gpu/drm/tegra/output.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/drivers/gpu/drm/tegra/output.c b/drivers/gpu/drm/tegra/output.c
> index 49e4f63a5550..360c4f83a4f8 100644
> --- a/drivers/gpu/drm/tegra/output.c
> +++ b/drivers/gpu/drm/tegra/output.c
> @@ -39,6 +39,9 @@ int tegra_output_connector_get_modes(struct drm_connector *connector)
>  	else if (output->ddc)
>  		drm_edid = drm_edid_read_ddc(connector, output->ddc);
>  
> +	if (!drm_edid)
> +		return 0;
> +
>  	drm_edid_connector_update(connector, drm_edid);
>  	cec_notifier_set_phys_addr(output->cec,
>  				   connector->display_info.source_physical_address);

-- 
Jani Nikula, Intel

      reply	other threads:[~2025-03-05 17:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-05 15:40 [PATCH] drm/tegra: Handle EDID allocation failures in tegra_output_connector_get_modes() Wentao Liang
2025-03-05 17:17 ` Jani Nikula [this message]

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=874j07xuqs.fsf@intel.com \
    --to=jani.nikula@linux.intel.com \
    --cc=airlied@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jonathanh@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=mperttunen@nvidia.com \
    --cc=simona@ffwll.ch \
    --cc=stable@vger.kernel.org \
    --cc=thierry.reding@gmail.com \
    --cc=vulab@iscas.ac.cn \
    /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