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, airlied@redhat.com, bskeggs@redhat.com
Cc: dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] drm/nouveau: fix null pointer dereference in nouveau_connector_get_modes
Date: Fri, 28 Jun 2024 13:54:51 -0400 [thread overview]
Message-ID: <c7f963fa69a8bff65c54dbacad4c890ce26f57a4.camel@redhat.com> (raw)
In-Reply-To: <20240627022732.2978601-1-make24@iscas.ac.cn>
Reviewed-by: Lyude Paul <lyude@redhat.com>
Will push this upstream in just a moment, thanks!
On Thu, 2024-06-27 at 10:27 +0800, Ma Ke wrote:
> In nouveau_connector_get_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(). Add a check to avoid
> npd.
>
> Fixes: 6ee738610f41 ("drm/nouveau: Add DRM driver for NVIDIA GPUs")
> Signed-off-by: Ma Ke <make24@iscas.ac.cn>
> ---
> Changes in v2:
> - modified the patch according to suggestions.
> ---
> drivers/gpu/drm/nouveau/nouveau_connector.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c
> b/drivers/gpu/drm/nouveau/nouveau_connector.c
> index 856b3ef5edb8..0c71d761d378 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_connector.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_connector.c
> @@ -1001,6 +1001,9 @@ nouveau_connector_get_modes(struct
> drm_connector *connector)
> struct drm_display_mode *mode;
>
> mode = drm_mode_duplicate(dev, nv_connector-
> >native_mode);
> + if (!mode)
> + return 0;
> +
> drm_mode_probed_add(connector, mode);
> ret = 1;
> }
--
Cheers,
Lyude Paul (she/her)
Software Engineer at Red Hat
prev parent reply other threads:[~2024-06-28 17:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-27 2:27 Ma Ke
2024-06-28 17:54 ` 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=c7f963fa69a8bff65c54dbacad4c890ce26f57a4.camel@redhat.com \
--to=lyude@redhat.com \
--cc=airlied@gmail.com \
--cc=airlied@redhat.com \
--cc=bskeggs@redhat.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 \
/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
all inboxes | Powered by JetHome®