]> www.infradead.org Git - nvme.git/commit
s390/pci: Fix potential double remove of hotplug slot
authorNiklas Schnelle <schnelle@linux.ibm.com>
Mon, 25 Nov 2024 15:02:38 +0000 (16:02 +0100)
committerHeiko Carstens <hca@linux.ibm.com>
Thu, 28 Nov 2024 13:12:04 +0000 (14:12 +0100)
commitc4a585e952ca403a370586d3f16e8331a7564901
tree67cf1952f2cd9bf91388fe35ff63d3c9367634ec
parent48796104c864cf4dafa80bd8c2ce88f9c92a65ea
s390/pci: Fix potential double remove of hotplug slot

In commit 6ee600bfbe0f ("s390/pci: remove hotplug slot when releasing the
device") the zpci_exit_slot() was moved from zpci_device_reserved() to
zpci_release_device() with the intention of keeping the hotplug slot
around until the device is actually removed.

Now zpci_release_device() is only called once all references are
dropped. Since the zPCI subsystem only drops its reference once the
device is in the reserved state it follows that zpci_release_device()
must only deal with devices in the reserved state. Despite that it
contains code to tear down from both configured and standby state. For
the standby case this already includes the removal of the hotplug slot
so would cause a double removal if a device was ever removed in
either configured or standby state.

Instead of causing a potential double removal in a case that should
never happen explicitly WARN_ON() if a device in non-reserved state is
released and get rid of the dead code cases.

Fixes: 6ee600bfbe0f ("s390/pci: remove hotplug slot when releasing the device")
Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com>
Reviewed-by: Gerd Bayer <gbayer@linux.ibm.com>
Tested-by: Gerd Bayer <gbayer@linux.ibm.com>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
arch/s390/pci/pci.c