Commit 7f5b6a8e authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull pci fix from Bjorn Helgaas:

 - Prevent bwctrl NULL pointer dereference that caused hangs on shutdown
   on ASUS ROG Strix SCAR 17 G733PYV (Lukas Wunner)

* tag 'pci-v6.13-fixes-3' of git://git.kernel.org/pub/scm/linux/kernel/git/pci/pci:
  PCI/bwctrl: Fix NULL pointer deref on unbind and bind
parents c3812b15 15b8968d
Loading
Loading
Loading
Loading
+16 −9
Original line number Diff line number Diff line
@@ -303,14 +303,17 @@ static int pcie_bwnotif_probe(struct pcie_device *srv)
	if (ret)
		return ret;

	ret = devm_request_irq(&srv->device, srv->irq, pcie_bwnotif_irq,
	scoped_guard(rwsem_write, &pcie_bwctrl_setspeed_rwsem) {
		scoped_guard(rwsem_write, &pcie_bwctrl_lbms_rwsem) {
			port->link_bwctrl = data;

			ret = request_irq(srv->irq, pcie_bwnotif_irq,
					  IRQF_SHARED, "PCIe bwctrl", srv);
	if (ret)
			if (ret) {
				port->link_bwctrl = NULL;
				return ret;
			}

	scoped_guard(rwsem_write, &pcie_bwctrl_setspeed_rwsem) {
		scoped_guard(rwsem_write, &pcie_bwctrl_lbms_rwsem) {
			port->link_bwctrl = no_free_ptr(data);
			pcie_bwnotif_enable(srv);
		}
	}
@@ -331,12 +334,16 @@ static void pcie_bwnotif_remove(struct pcie_device *srv)

	pcie_cooling_device_unregister(data->cdev);

	scoped_guard(rwsem_write, &pcie_bwctrl_setspeed_rwsem) {
		scoped_guard(rwsem_write, &pcie_bwctrl_lbms_rwsem) {
			pcie_bwnotif_disable(srv->port);

	scoped_guard(rwsem_write, &pcie_bwctrl_setspeed_rwsem)
		scoped_guard(rwsem_write, &pcie_bwctrl_lbms_rwsem)
			free_irq(srv->irq, srv);

			srv->port->link_bwctrl = NULL;
		}
	}
}

static int pcie_bwnotif_suspend(struct pcie_device *srv)
{