public inbox for linux-s390@vger.kernel.org
 help / color / mirror / Atom feed
From: Gerd Bayer <gbayer@linux.ibm.com>
To: Niklas Schnelle <schnelle@linux.ibm.com>
Cc: linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-pci@vger.kernel.org,
	Gerald Schaefer <gerald.schaefer@linux.ibm.com>,
	Heiko Carstens <hca@linux.ibm.com>,
	Vasily Gorbik <gor@linux.ibm.com>,
	Alexander Gordeev <agordeev@linux.ibm.com>,
	Christian Borntraeger <borntraeger@linux.ibm.com>,
	Sven Schnelle <svens@linux.ibm.com>,
	Bjorn Helgaas <bhelgaas@google.com>,
	Pierre Morel <pmorel@linux.ibm.com>,
	Matthew Rosato <mjrosato@linux.ibm.com>
Subject: Re: [PATCH] PCI: s390: Fix use-after-free of PCI bus resources with s390 per-function hotplug
Date: Tue, 14 Feb 2023 10:46:45 +0100	[thread overview]
Message-ID: <bce832f7305a132fc2e2b47fc668292234820465.camel@linux.ibm.com> (raw)
In-Reply-To: <20230203114807.3461308-1-schnelle@linux.ibm.com>

Hi Niklas,

when comparing pci_bus_remove_resource with pci_bus_remove_resources,
I find that the "single-resource" variant might be ending too early.

On Fri, 2023-02-03 at 12:48 +0100, Niklas Schnelle wrote:
> +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;
                          ^^^^^^^
Did you mean to "break" here, rather than end the routine?
> +               }
> +       }
> +
> +       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;
                          ^^^^^^^
Here "break" and "return" have the same effect, but "break" would be
"symmetric".
> +               }
> +       }
> +       return;
> +
> +}

While this might be a nit, I'd like to better separate the "single-
resource" variant's name. How about pci_bus_remove_one_resource - I
know it's getting long...

Thanks,
Gerd

  reply	other threads:[~2023-02-14  9:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-03 11:48 [PATCH] PCI: s390: Fix use-after-free of PCI bus resources with s390 per-function hotplug Niklas Schnelle
2023-02-14  9:46 ` Gerd Bayer [this message]
2023-02-14 10:00   ` Niklas Schnelle

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=bce832f7305a132fc2e2b47fc668292234820465.camel@linux.ibm.com \
    --to=gbayer@linux.ibm.com \
    --cc=agordeev@linux.ibm.com \
    --cc=bhelgaas@google.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=gerald.schaefer@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@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=pmorel@linux.ibm.com \
    --cc=schnelle@linux.ibm.com \
    --cc=svens@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