linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] PCIE/PME: fix possible use-after-free on remove
@ 2019-03-01 16:54 Sven Van Asbroeck
  2019-03-02  0:11 ` Bjorn Helgaas
  0 siblings, 1 reply; 2+ messages in thread
From: Sven Van Asbroeck @ 2019-03-01 16:54 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: linux-pci, linux-kernel, Sinan Kaya, Frederick Lawler,
	Mika Westerberg, Keith Busch, Rafael J . Wysocki

In remove(), ensure that the pme work cannot run after kfree()
is called. Otherwise, this could result in a use-after-free.

This issue was detected with the help of Coccinelle.

Cc: Sinan Kaya <okaya@kernel.org>
Cc: Frederick Lawler <fred@fredlawl.com>
Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: Keith Busch <keith.busch@intel.com>
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Sven Van Asbroeck <TheSven73@gmail.com>
---
 drivers/pci/pcie/pme.c | 1 +
 1 file changed, 1 insertion(+)

v2:
	rebased against Bjorn Helgaas's pcm/pm branch at
	git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git

diff --git a/drivers/pci/pcie/pme.c b/drivers/pci/pcie/pme.c
index efa5b552914b..54d593d10396 100644
--- a/drivers/pci/pcie/pme.c
+++ b/drivers/pci/pcie/pme.c
@@ -437,6 +437,7 @@ static void pcie_pme_remove(struct pcie_device *srv)
 
 	pcie_pme_disable_interrupt(srv->port, data);
 	free_irq(srv->irq, srv);
+	cancel_work_sync(&data->work);
 	kfree(data);
 }
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-03-02  0:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-01 16:54 [PATCH v2] PCIE/PME: fix possible use-after-free on remove Sven Van Asbroeck
2019-03-02  0:11 ` Bjorn Helgaas

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).