Skip to content

Commit 7f5b6a8

Browse files
committed
Merge tag 'pci-v6.13-fixes-3' of git://git.kernel.org/pub/scm/linux/kernel/git/pci/pci
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
2 parents c3812b1 + 15b8968 commit 7f5b6a8

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

drivers/pci/pcie/bwctrl.c

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -303,14 +303,17 @@ static int pcie_bwnotif_probe(struct pcie_device *srv)
303303
if (ret)
304304
return ret;
305305

306-
ret = devm_request_irq(&srv->device, srv->irq, pcie_bwnotif_irq,
307-
IRQF_SHARED, "PCIe bwctrl", srv);
308-
if (ret)
309-
return ret;
310-
311306
scoped_guard(rwsem_write, &pcie_bwctrl_setspeed_rwsem) {
312307
scoped_guard(rwsem_write, &pcie_bwctrl_lbms_rwsem) {
313-
port->link_bwctrl = no_free_ptr(data);
308+
port->link_bwctrl = data;
309+
310+
ret = request_irq(srv->irq, pcie_bwnotif_irq,
311+
IRQF_SHARED, "PCIe bwctrl", srv);
312+
if (ret) {
313+
port->link_bwctrl = NULL;
314+
return ret;
315+
}
316+
314317
pcie_bwnotif_enable(srv);
315318
}
316319
}
@@ -331,11 +334,15 @@ static void pcie_bwnotif_remove(struct pcie_device *srv)
331334

332335
pcie_cooling_device_unregister(data->cdev);
333336

334-
pcie_bwnotif_disable(srv->port);
337+
scoped_guard(rwsem_write, &pcie_bwctrl_setspeed_rwsem) {
338+
scoped_guard(rwsem_write, &pcie_bwctrl_lbms_rwsem) {
339+
pcie_bwnotif_disable(srv->port);
340+
341+
free_irq(srv->irq, srv);
335342

336-
scoped_guard(rwsem_write, &pcie_bwctrl_setspeed_rwsem)
337-
scoped_guard(rwsem_write, &pcie_bwctrl_lbms_rwsem)
338343
srv->port->link_bwctrl = NULL;
344+
}
345+
}
339346
}
340347

341348
static int pcie_bwnotif_suspend(struct pcie_device *srv)

0 commit comments

Comments
 (0)