From: Lyude Paul <lyude@redhat.com>
To: Ma Ke <make24@iscas.ac.cn>,
kherbst@redhat.com, dakr@redhat.com, airlied@gmail.com,
daniel@ffwll.ch
Cc: dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] drm/nouveau/dispnv04: fix null pointer dereference in nv17_tv_get_hd_modes
Date: Tue, 25 Jun 2024 15:11:41 -0400 [thread overview]
Message-ID: <30a2ae4b3ac161012168a6d03cd28c616829eb22.camel@redhat.com> (raw)
In-Reply-To: <20240625081029.2619437-1-make24@iscas.ac.cn>
Reviewed-by: Lyude Paul <lyude@redhat.com>
I will push this and the other patch that you sent upstream in just a
moment, thanks!
On Tue, 2024-06-25 at 16:10 +0800, Ma Ke wrote:
> In nv17_tv_get_hd_modes(), the return value of drm_mode_duplicate()
> is
> assigned to mode, which will lead to a possible NULL pointer
> dereference
> on failure of drm_mode_duplicate(). The same applies to
> drm_cvt_mode().
> Add a check to avoid null pointer dereference.
>
> Cc: stable@vger.kernel.org
> Signed-off-by: Ma Ke <make24@iscas.ac.cn>
> ---
> drivers/gpu/drm/nouveau/dispnv04/tvnv17.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c
> b/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c
> index 670c9739e5e1..9c3dc9a5bb46 100644
> --- a/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c
> +++ b/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c
> @@ -258,6 +258,8 @@ static int nv17_tv_get_hd_modes(struct
> drm_encoder *encoder,
> if (modes[i].hdisplay == output_mode->hdisplay &&
> modes[i].vdisplay == output_mode->vdisplay) {
> mode = drm_mode_duplicate(encoder->dev,
> output_mode);
> + if (!mode)
> + continue;
> mode->type |= DRM_MODE_TYPE_PREFERRED;
>
> } else {
> @@ -265,6 +267,8 @@ static int nv17_tv_get_hd_modes(struct
> drm_encoder *encoder,
> modes[i].vdisplay, 60,
> false,
> (output_mode->flags &
>
> DRM_MODE_FLAG_INTERLACE), false);
> + if (!mode)
> + continue;
> }
>
> /* CVT modes are sometimes unsuitable... */
--
Cheers,
Lyude Paul (she/her)
Software Engineer at Red Hat
prev parent reply other threads:[~2024-06-25 19:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-25 8:10 [PATCH] drm/nouveau/dispnv04: fix null pointer dereference in nv17_tv_get_hd_modes Ma Ke
2024-06-25 14:34 ` Markus Elfring
2024-06-25 19:11 ` Lyude Paul [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=30a2ae4b3ac161012168a6d03cd28c616829eb22.camel@redhat.com \
--to=lyude@redhat.com \
--cc=airlied@gmail.com \
--cc=dakr@redhat.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=kherbst@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=make24@iscas.ac.cn \
--cc=nouveau@lists.freedesktop.org \
--cc=stable@vger.kernel.org \
/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