linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lukas Wunner <lukas@wunner.de>
To: Niklas Schnelle <schnelle@linux.ibm.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>,
	Gerd Bayer <gbayer@linux.ibm.com>,
	Matthew Rosato <mjrosato@linux.ibm.com>,
	linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-pci@vger.kernel.org, Andy Shevchenko <andy@kernel.org>
Subject: Re: [PATCH v2 1/4] PCI: s390: Fix use-after-free of PCI resources with per-function hotplug
Date: Mon, 17 Apr 2023 09:46:33 +0200	[thread overview]
Message-ID: <20230417074633.GA12881@wunner.de> (raw)
In-Reply-To: <20230306151014.60913-2-schnelle@linux.ibm.com>

On Mon, Mar 06, 2023 at 04:10:11PM +0100, Niklas Schnelle wrote:
> --- a/drivers/pci/bus.c
> +++ b/drivers/pci/bus.c
> @@ -76,6 +76,27 @@ struct resource *pci_bus_resource_n(const struct pci_bus *bus, int n)
>  }
>  EXPORT_SYMBOL_GPL(pci_bus_resource_n);
>  
> +void pci_bus_remove_resource(struct pci_bus *bus, struct resource *res)
> +{
> +	struct pci_bus_resource *bus_res, *tmp;
> +	int i;
> +
> +	for (i = 0; i < PCI_BRIDGE_RESOURCE_NUM; i++) {
> +		if (bus->resource[i] == res) {
> +			bus->resource[i] = NULL;
> +			return;
> +		}
> +	}
> +
> +	list_for_each_entry_safe(bus_res, tmp, &bus->resources, list) {
> +		if (bus_res->res == res) {
> +			list_del(&bus_res->list);
> +			kfree(bus_res);
> +			return;
> +		}
> +	}
> +}

I realize this has already been applied so s390.git/master,
but nevertheless would like to point out there's a handy
pci_bus_for_each_resource() helper which could have been
used here instead of the for-loop.

Sorry for chiming in late, I just spotted this while flushing out
my inbox.

Adding Andy to cc: who's been active in this area recently.

Thanks,

Lukas

  parent reply	other threads:[~2023-04-17  7:46 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-06 15:10 [PATCH v2 0/4] PCI: s390: Fix user-after-free and clean up Niklas Schnelle
2023-03-06 15:10 ` [PATCH v2 1/4] PCI: s390: Fix use-after-free of PCI resources with per-function hotplug Niklas Schnelle
2023-03-08 23:14   ` Bjorn Helgaas
2023-03-09 16:39     ` Niklas Schnelle
2023-03-10 10:29     ` Vasily Gorbik
2023-03-09 18:18   ` Matthew Rosato
2023-04-17  7:46   ` Lukas Wunner [this message]
2023-04-17 10:07     ` Andy Shevchenko
2023-03-06 15:10 ` [PATCH v2 2/4] s390/pci: only add specific device in zpci_bus_scan_device() Niklas Schnelle
2023-03-09 18:36   ` Matthew Rosato
2023-03-06 15:10 ` [PATCH v2 3/4] s390/pci: remove redundant pci_bus_add_devices() on new bus Niklas Schnelle
2023-03-09 19:14   ` Matthew Rosato
2023-03-06 15:10 ` [PATCH v2 4/4] s390/pci: clean up left over special treatment for function zero Niklas Schnelle
2023-03-09 18:37   ` Matthew Rosato

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=20230417074633.GA12881@wunner.de \
    --to=lukas@wunner.de \
    --cc=andy@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=gbayer@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=mjrosato@linux.ibm.com \
    --cc=schnelle@linux.ibm.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).