From: Dan Carpenter <dan.carpenter@oracle.com>
To: benh@kernel.crashing.org
Cc: linux-pci@vger.kernel.org
Subject: [bug report] PCI: Protect pci_reassign_bridge_resources() against addition/removal
Date: Wed, 4 Sep 2019 13:03:03 +0300 [thread overview]
Message-ID: <20190904100303.GD7007@mwanda> (raw)
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'.
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
next reply other threads:[~2019-09-04 10:05 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-04 10:03 Dan Carpenter [this message]
2019-09-09 8:13 ` [bug report] PCI: Protect pci_reassign_bridge_resources() against addition/removal Benjamin Herrenschmidt
2019-09-23 21:50 ` Bjorn Helgaas
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=20190904100303.GD7007@mwanda \
--to=dan.carpenter@oracle.com \
--cc=benh@kernel.crashing.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.