linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Dan Carpenter <dan.carpenter@oracle.com>, linux-pci@vger.kernel.org
Subject: Re: [bug report] PCI: Protect pci_reassign_bridge_resources() against addition/removal
Date: Mon, 23 Sep 2019 16:50:55 -0500	[thread overview]
Message-ID: <20190923215055.GB11938@google.com> (raw)
In-Reply-To: <d13c8d6b6bebba12331199200431fa407c5c1e1b.camel@kernel.crashing.org>

On Mon, Sep 09, 2019 at 09:13:28AM +0100, Benjamin Herrenschmidt wrote:
> On Wed, 2019-09-04 at 13:03 +0300, Dan Carpenter wrote:
> > Hello Benjamin Herrenschmidt,
> > 
> > The patch 540f62d26f02: "PCI: Protect pci_reassign_bridge_resources()
> > against addition/removal" from Jun 24, 2019, leads to the following
> > static checker warning:
> > 
> > 	drivers/pci/setup-bus.c:2158 pci_reassign_bridge_resources()
> > 	warn: inconsistent returns 'read_sem:&pci_bus_sem'.
> 
> Thanks, I missed that. I'll try to send something but from Plumbers
> might be difficult...

I dropped this for now.

> > drivers/pci/setup-bus.c
> >   2066          unsigned int i;
> >   2067          int ret;
> >   2068  
> >   2069          down_read(&pci_bus_sem);
> > 
> > We added some new locking here.
> > 
> >   2070  
> >   2071          /* Walk to the root hub, releasing bridge BARs when
> > possible */
> >   2072          next = bridge;
> >   2073          do {
> >   2074                  bridge = next;
> >   2075                  for (i = PCI_BRIDGE_RESOURCES; i <
> > PCI_BRIDGE_RESOURCE_END;
> >   2076                       i++) {
> >   2077                          struct resource *res = &bridge-
> > >resource[i];
> >   2078  
> >   2079                          if ((res->flags ^ type) &
> > PCI_RES_TYPE_MASK)
> >   2080                                  continue;
> >   2081  
> >   2082                          /* Ignore BARs which are still in use
> > */
> >   2083                          if (res->child)
> >   2084                                  continue;
> >   2085  
> >   2086                          ret = add_to_list(&saved, bridge,
> > res, 0, 0);
> >   2087                          if (ret)
> >   2088                                  goto cleanup;
> >   2089  
> >   2090                          pci_info(bridge, "BAR %d: releasing
> > %pR\n",
> >   2091                                   i, res);
> >   2092  
> >   2093                          if (res->parent)
> >   2094                                  release_resource(res);
> >   2095                          res->start = 0;
> >   2096                          res->end = 0;
> >   2097                          break;
> >   2098                  }
> >   2099                  if (i == PCI_BRIDGE_RESOURCE_END)
> >   2100                          break;
> >   2101  
> >   2102                  next = bridge->bus ? bridge->bus->self :
> > NULL;
> >   2103          } while (next);
> >   2104  
> >   2105          if (list_empty(&saved))
> >   2106                  return -ENOENT;
> > 
> > This needs an unlock.  It's not clear to me if any other clean up is
> > required, but possibly it's worth looking at.
> > 
> >   2107  
> >   2108          __pci_bus_size_bridges(bridge->subordinate, &added);
> >   2109          __pci_bridge_assign_resources(bridge, &added,
> > &failed);
> > 
> > regards,
> > dan carpenter
> 

      reply	other threads:[~2019-09-23 21:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-04 10:03 [bug report] PCI: Protect pci_reassign_bridge_resources() against addition/removal Dan Carpenter
2019-09-09  8:13 ` Benjamin Herrenschmidt
2019-09-23 21:50   ` Bjorn Helgaas [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=20190923215055.GB11938@google.com \
    --to=helgaas@kernel.org \
    --cc=benh@kernel.crashing.org \
    --cc=dan.carpenter@oracle.com \
    --cc=linux-pci@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;
as well as URLs for NNTP newsgroup(s).