Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] pci-hyperv: logical device ID leaked on remove after failed resume --
commit 60c40edaf8c7fd1e4ba684f1b2ec029a89674f03 Author: Yu Zhang <[email protected]> Drivers: hv: Add logical device ID registry for vPCI devices This commit adds a registry in hv_common.c that maps a PCI domain number to its logical device ID prefix. The vPCI bus driver registers the prefix when a bus is probed and unregisters it when the bus is removed. > diff --git a/drivers/pci/controller/pci-hyperv.c > b/drivers/pci/controller/pci-hyperv.c > index 89816a2bd7cd3..db70be47af6e1 100644 > --- a/drivers/pci/controller/pci-hyperv.c > +++ b/drivers/pci/controller/pci-hyperv.c [ ... ] > @@ -3978,6 +3985,8 @@ static void hv_pci_remove(struct hv_device *hdev) > > hbus = hv_get_drvdata(hdev); > if (hbus->state == hv_pcibus_installed) { > + int dom = hbus->bridge->domain_nr; > + > tasklet_disable(&hdev->channel->callback_event); > hbus->state = hv_pcibus_removing; > tasklet_enable(&hdev->channel->callback_event); > @@ -3995,6 +4004,8 @@ static void hv_pci_remove(struct hv_device *hdev) > hv_pci_remove_slots(hbus); > pci_remove_root_bus(hbus->bridge->bus); > pci_unlock_rescan_remove(); > + > + hv_pci_unregister_dev_id(dom); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [Severity: Medium] Does this code leak the logical device ID if hv_pci_resume() fails? If the device suspends and hv_pci_resume() fails, it leaves hbus->state as hv_pcibus_init (or if hv_pci_suspend() fails, it leaves it as hv_pcibus_removing). Later, when the device is unbound and hv_pci_remove() is called, it skips this if (hbus->state == hv_pcibus_installed) block, omitting the required hv_pci_unregister_dev_id() call. This will cause a memory leak of struct hv_pci_busdata and its hash table entry. Because the domain remains registered, any subsequent probe (e.g., driver re-bind) will fail with -EEXIST in hv_pci_register_dev_id(), permanently disabling the device until reboot. Although the underlying hbus->state mishandling is pre-existing, the leaked registry and the resulting -EEXIST probe failure are introduced in this patch. > } > > hv_pci_bus_exit(hdev, false); -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=2
