From: Thomas Zimmermann <tzimmermann@suse.de>
To: Ma Ke <make24@iscas.ac.cn>,
maarten.lankhorst@linux.intel.com, mripard@kernel.org,
airlied@gmail.com, daniel@ffwll.ch, noralf@tronnes.org,
sam@ravnborg.org
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH v4 RESEND] drm/client: fix null pointer dereference in drm_client_modeset_probe
Date: Fri, 2 Aug 2024 09:17:00 +0200 [thread overview]
Message-ID: <f722998d-993a-4bd8-b1bb-af7b5e6cf6d5@suse.de> (raw)
In-Reply-To: <20240802044736.1570345-1-make24@iscas.ac.cn>
Am 02.08.24 um 06:47 schrieb Ma Ke:
> In drm_client_modeset_probe(), the return value of drm_mode_duplicate() is
> assigned to modeset->mode, which will lead to a possible NULL pointer
> dereference on failure of drm_mode_duplicate(). Add a check to avoid npd.
>
> Cc: stable@vger.kernel.org
> Fixes: cf13909aee05 ("drm/fb-helper: Move out modeset config code")
> Signed-off-by: Ma Ke <make24@iscas.ac.cn>
Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
> ---
> Changes in v4:
> - modified patch, set ret and break to handle error rightly.
> Changes in v3:
> - modified patch as suggestions, returned error directly when failing to
> get modeset->mode.
> Changes in v2:
> - added the recipient's email address, due to the prolonged absence of a
> response from the recipients.
> - added Cc stable.
> ---
> drivers/gpu/drm/drm_client_modeset.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_client_modeset.c b/drivers/gpu/drm/drm_client_modeset.c
> index 31af5cf37a09..cee5eafbfb81 100644
> --- a/drivers/gpu/drm/drm_client_modeset.c
> +++ b/drivers/gpu/drm/drm_client_modeset.c
> @@ -880,6 +880,11 @@ int drm_client_modeset_probe(struct drm_client_dev *client, unsigned int width,
>
> kfree(modeset->mode);
> modeset->mode = drm_mode_duplicate(dev, mode);
> + if (!modeset->mode) {
> + ret = -ENOMEM;
> + break;
> + }
> +
> drm_connector_get(connector);
> modeset->connectors[modeset->num_connectors++] = connector;
> modeset->x = offset->x;
--
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)
next prev parent reply other threads:[~2024-08-02 7:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-02 4:47 Ma Ke
2024-08-02 7:17 ` Thomas Zimmermann [this message]
2024-08-02 7:28 ` Thomas Zimmermann
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=f722998d-993a-4bd8-b1bb-af7b5e6cf6d5@suse.de \
--to=tzimmermann@suse.de \
--cc=airlied@gmail.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=make24@iscas.ac.cn \
--cc=mripard@kernel.org \
--cc=noralf@tronnes.org \
--cc=sam@ravnborg.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
all inboxes | Powered by JetHome®