All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Yu Zhang" <zhangyu1@linux.microsoft.com>
Cc: linux-hyperv@vger.kernel.org, linux-pci@vger.kernel.org
Subject: Re: [PATCH v6 2/5] Drivers: hv: Add logical device ID registry for vPCI devices
Date: Wed, 30 Sep 2026 14:26:20 +0000	[thread overview]
Message-ID: <20260930142620.CF91B1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260930141409.437904-3-zhangyu1@linux.microsoft.com>

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 <zhangyu1@linux.microsoft.com>
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/20260930141409.437904-1-zhangyu1@linux.microsoft.com?part=2

  reply	other threads:[~2026-09-30 14:26 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-30 14:14 [PATCH v6 0/5] Hyper-V: Add para-virtualized IOMMU support for Linux guests Yu Zhang
2026-09-30 14:14 ` [PATCH v6 1/5] hyperv: Introduce new hypercall interfaces used by Hyper-V guest IOMMU Yu Zhang
2026-09-30 14:27   ` sashiko-bot
2026-09-30 14:14 ` [PATCH v6 2/5] Drivers: hv: Add logical device ID registry for vPCI devices Yu Zhang
2026-09-30 14:26   ` sashiko-bot [this message]
2026-09-30 14:14 ` [PATCH v6 3/5] iommu/x86: Add architectural MSI reserved region helper Yu Zhang
2026-09-30 14:20   ` sashiko-bot
2026-10-01 12:07   ` Vasant Hegde
2026-09-30 14:14 ` [PATCH v6 4/5] iommu/hyperv: Add para-virtualized IOMMU support for Hyper-V guest Yu Zhang
2026-09-30 14:37   ` sashiko-bot
2026-09-30 14:14 ` [PATCH v6 5/5] iommu/hyperv: Add page-selective IOTLB flush support Yu Zhang
2026-09-30 14:36   ` sashiko-bot
2026-10-09  8:38 ` [PATCH v6 0/5] Hyper-V: Add para-virtualized IOMMU support for Linux guests Jörg Rödel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260930142620.CF91B1F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=zhangyu1@linux.microsoft.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.