From: Lyude Paul <lyude@redhat.com>
To: Ma Ke <make_ruc2021@163.com>,
airlied@gmail.com, daniel@ffwll.ch, javierm@redhat.com,
mripard@kernel.org, u.kleine-koenig@pengutronix.de,
noralf@tronnes.org, tzimmermann@suse.de
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drm/i2c/ch7006: fix a possible null pointer dereference
Date: Mon, 09 Oct 2023 17:45:48 -0400 [thread overview]
Message-ID: <2346aa93e2479f2ebd8849c5b2ead36a50ce43a0.camel@redhat.com> (raw)
In-Reply-To: <20231007031712.3997144-1-make_ruc2021@163.com>
On Sat, 2023-10-07 at 11:17 +0800, Ma Ke wrote:
> In ch7006_encoder_get_modes(), the return value of drm_mode_duplicate()
> is assigned to mode, which will lead to a NULL pointer dereference
> on failure of drm_mode_duplicate(). Add a check to avoid npd.
>
> Signed-off-by: Ma Ke <make_ruc2021@163.com>
> ---
> drivers/gpu/drm/i2c/ch7006_drv.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/i2c/ch7006_drv.c b/drivers/gpu/drm/i2c/ch7006_drv.c
> index 131512a5f3bd..27c2f02f5b43 100644
> --- a/drivers/gpu/drm/i2c/ch7006_drv.c
> +++ b/drivers/gpu/drm/i2c/ch7006_drv.c
> @@ -236,8 +236,10 @@ static int ch7006_encoder_get_modes(struct drm_encoder *encoder,
> ~mode->valid_norms & 1<<priv->norm)
> continue;
>
> - drm_mode_probed_add(connector,
> - drm_mode_duplicate(encoder->dev, &mode->mode));
> + struct drm_display_mode *encoder_mode;
> + encoder_mode = drm_mode_duplicate(encoder->dev, &mode->mode);
I think the kernel prefers to have variable declaration at the top of the
scope, and as well: this breaks things because you don't add back the
drm_mode_probed_add() call.
> + if (!mode)
> + continue;
>
> n++;
> }
--
Cheers,
Lyude Paul (she/her)
Software Engineer at Red Hat
prev parent reply other threads:[~2023-10-09 21:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-07 3:17 Ma Ke
2023-10-07 5:17 ` kernel test robot
2023-10-09 21:45 ` 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=2346aa93e2479f2ebd8849c5b2ead36a50ce43a0.camel@redhat.com \
--to=lyude@redhat.com \
--cc=airlied@gmail.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=javierm@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=make_ruc2021@163.com \
--cc=mripard@kernel.org \
--cc=noralf@tronnes.org \
--cc=tzimmermann@suse.de \
--cc=u.kleine-koenig@pengutronix.de \
/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®