mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nathan Chancellor <nathan@kernel.org>
To: Nick Desaulniers <ndesaulniers@google.com>
Cc: "José Expósito" <jose.exposito89@gmail.com>,
	mripard@kernel.org, emma@anholt.net, airlied@gmail.com,
	daniel@ffwll.ch, dri-devel@lists.freedesktop.org,
	linux-kernel@vger.kernel.org, llvm@lists.linux.dev
Subject: Re: [PATCH v2 2/2] drm/vc4: hdmi: Fix pointer dereference before check
Date: Thu, 17 Nov 2022 10:32:01 -0700	[thread overview]
Message-ID: <Y3ZwEc4x/wIsroTI@dev-arch.thelio-3990X> (raw)
In-Reply-To: <20221117172849.hk7bgahjbvycml5v@google.com>

On Thu, Nov 17, 2022 at 09:28:49AM -0800, Nick Desaulniers wrote:
> On Thu, Nov 10, 2022 at 02:47:52PM +0100, José Expósito wrote:
> > Commit 6bed2ea3cb38 ("drm/vc4: hdmi: Reset link on hotplug") introduced
> > the vc4_hdmi_reset_link() function. This function dereferences the
> > "connector" pointer before checking whether it is NULL or not.
> > 
> > Rework variable assignment to avoid this issue.
> > 
> > Fixes: 6bed2ea3cb38 ("drm/vc4: hdmi: Reset link on hotplug")
> > Signed-off-by: José Expósito <jose.exposito89@gmail.com>
> > ---
> >  drivers/gpu/drm/vc4/vc4_hdmi.c | 6 ++++--
> >  1 file changed, 4 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c
> > index a49f88e5d2b9..6b223a5fcf6f 100644
> > --- a/drivers/gpu/drm/vc4/vc4_hdmi.c
> > +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
> > @@ -318,8 +318,8 @@ static int reset_pipe(struct drm_crtc *crtc,
> >  static int vc4_hdmi_reset_link(struct drm_connector *connector,
> >  			       struct drm_modeset_acquire_ctx *ctx)
> >  {
> > -	struct drm_device *drm = connector->dev;
> > -	struct vc4_hdmi *vc4_hdmi = connector_to_vc4_hdmi(connector);
> > +	struct drm_device *drm;
> > +	struct vc4_hdmi *vc4_hdmi;
> 
> Hi, I think this change, or another in this area recently, is causing
> the following warning. PTAL
> 
> drivers/gpu/drm/vc4/vc4_hdmi.c:351:14: warning: variable 'vc4_hdmi' is uninitialized when used here [-Wuninitialized]
>         mutex_lock(&vc4_hdmi->mutex);
>                     ^~~~~~~~
> drivers/gpu/drm/vc4/vc4_hdmi.c:322:27: note: initialize the variable 'vc4_hdmi' to silence this warning
>         struct vc4_hdmi *vc4_hdmi;
>                                  ^
>                                   = NULL

Guess we just crossed paths but this is just a problem with -next due to
a bad conflict resolution on Stephen's part:

https://lore.kernel.org/Y3ZvffZiR+SgtY6h@dev-arch.thelio-3990X/

> >  	struct drm_connector_state *conn_state;
> >  	struct drm_crtc_state *crtc_state;
> >  	struct drm_crtc *crtc;
> > @@ -330,6 +330,7 @@ static int vc4_hdmi_reset_link(struct drm_connector *connector,
> >  	if (!connector)
> >  		return 0;
> >  
> > +	drm = connector->dev;
> >  	ret = drm_modeset_lock(&drm->mode_config.connection_mutex, ctx);
> >  	if (ret)
> >  		return ret;
> > @@ -347,6 +348,7 @@ static int vc4_hdmi_reset_link(struct drm_connector *connector,
> >  	if (!crtc_state->active)
> >  		return 0;
> >  
> > +	vc4_hdmi = connector_to_vc4_hdmi(connector);

This version of the patch is fine, as there is no mutex_lock() call
here.

> >  	if (!vc4_hdmi_supports_scrambling(vc4_hdmi))
> >  		return 0;
> >  
> > -- 
> > 2.25.1
> > 
> > 
> 

Cheers,
Nathan

      reply	other threads:[~2022-11-17 17:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-10 13:47 [PATCH v2 0/2] " José Expósito
2022-11-10 13:47 ` [PATCH v2 1/2] drm/vc4: hdmi: Pass vc4_hdmi to vc4_hdmi_supports_scrambling() José Expósito
2022-11-10 13:47 ` [PATCH v2 2/2] drm/vc4: hdmi: Fix pointer dereference before check José Expósito
2022-11-17 17:28   ` Nick Desaulniers
2022-11-17 17:32     ` Nathan Chancellor [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=Y3ZwEc4x/wIsroTI@dev-arch.thelio-3990X \
    --to=nathan@kernel.org \
    --cc=airlied@gmail.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=emma@anholt.net \
    --cc=jose.exposito89@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=mripard@kernel.org \
    --cc=ndesaulniers@google.com \
    /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®