linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Mathias Nyman <mathias.nyman@intel.com>,
	Jonathan Hunter <jonathanh@nvidia.com>,
	linux-usb@vger.kernel.org, linux-tegra@vger.kernel.org
Subject: xhci: tegra: Prevent error pointer dereference
Date: Wed, 20 Feb 2019 17:27:02 +0100	[thread overview]
Message-ID: <20190220162702.GA21303@ulmo> (raw)

On Wed, Feb 20, 2019 at 05:16:12PM +0100, Greg Kroah-Hartman wrote:
> On Wed, Feb 20, 2019 at 02:48:41PM +0100, Thierry Reding wrote:
> > From: Thierry Reding <treding@nvidia.com>
> > 
> > During initialization, the host and super-speed power domains will
> > contain an ERR_PTR() encoded error code rather than being NULL. To
> > avoid a crash, use a !IS_ERR_OR_NULL() condition during cleanup.
> > 
> > Signed-off-by: Thierry Reding <treding@nvidia.com>
> > ---
> >  drivers/usb/host/xhci-tegra.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c
> > index 938ff06c0349..efb0cad8710e 100644
> > --- a/drivers/usb/host/xhci-tegra.c
> > +++ b/drivers/usb/host/xhci-tegra.c
> > @@ -941,9 +941,9 @@ static void tegra_xusb_powerdomain_remove(struct device *dev,
> >  		device_link_del(tegra->genpd_dl_ss);
> >  	if (tegra->genpd_dl_host)
> >  		device_link_del(tegra->genpd_dl_host);
> > -	if (tegra->genpd_dev_ss)
> > +	if (!IS_ERR_OR_NULL(tegra->genpd_dev_ss))
> >  		dev_pm_domain_detach(tegra->genpd_dev_ss, true);
> > -	if (tegra->genpd_dev_host)
> > +	if (!IS_ERR_OR_NULL(tegra->genpd_dev_host))
> >  		dev_pm_domain_detach(tegra->genpd_dev_host, true);
> >  }
> 
> Should this go to older kernels?  If so, any hint as to what commit this
> "fixes:"?

Technically this:

Fixes: 6494a9ad86de ("usb: xhci: tegra: Add genpd support")

which was merged into v4.20.

However, I have never seen this actually crash on current kernels and
only came across it while working on a change to reset controls which
can cause dev_pm_domain_attach_by_name() to fail. That function can't
fail in current kernels, so I don't think we need to fix this in old
kernels. So if we can get this into v5.0, that'd be good enough for
me.

Thierry

             reply	other threads:[~2019-02-20 16:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-20 16:27 Thierry Reding [this message]
  -- strict thread matches above, loose matches on Subject: below --
2019-02-20 16:36 xhci: tegra: Prevent error pointer dereference Mathias Nyman
2019-02-20 16:31 Greg Kroah-Hartman
2019-02-20 16:16 Greg Kroah-Hartman
2019-02-20 14:41 Jon Hunter
2019-02-20 13:48 Thierry Reding

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=20190220162702.GA21303@ulmo \
    --to=thierry.reding@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jonathanh@nvidia.com \
    --cc=linux-tegra@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@intel.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;
as well as URLs for NNTP newsgroup(s).