All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Yu Zhang" <zhangyu1@linux.microsoft.com>
Cc: linux-pci@vger.kernel.org, linux-hyperv@vger.kernel.org
Subject: Re: [PATCH v5 4/5] iommu/hyperv: Add para-virtualized IOMMU support for Hyper-V guest
Date: Fri, 04 Sep 2026 08:16:03 +0000	[thread overview]
Message-ID: <20260904081603.74FDB1F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260904075512.174154-5-zhangyu1@linux.microsoft.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The global pointer `hv_iommu_device` is left pointing to freed memory on initialization error paths.
--

commit cabf0b0a28725bbdf8a09d64a7c284187b9174dc
Author: Yu Zhang <zhangyu1@linux.microsoft.com>

iommu/hyperv: Add para-virtualized IOMMU support for Hyper-V guest

This commit introduces a para-virtualized IOMMU driver for Linux guests on
Hyper-V. It implements stage-1 IO translation within the guest OS by utilizing
Hyper-V hypercalls.

> diff --git a/drivers/iommu/hyperv/hv-iommu-guest.c b/drivers/iommu/hyperv/hv-iommu-guest.c
> new file mode 100644
> index 0000000000000..137f232d74fe5
> --- /dev/null
> +++ b/drivers/iommu/hyperv/hv-iommu-guest.c
[ ... ]
> +static void __init
> +hv_init_iommu_device(struct hv_iommu_dev *hv_iommu,
> +		     struct hv_output_get_iommu_capabilities *hv_iommu_cap)
> +{
[ ... ]
> +	hv_iommu_device = hv_iommu;
> +}
> +
> +int __init hv_iommu_init(void)
> +{
[ ... ]
> +	hv_iommu = kzalloc_obj(*hv_iommu, GFP_KERNEL);
> +	if (!hv_iommu)
> +		return -ENOMEM;
> +
> +	hv_init_iommu_device(hv_iommu, &hv_iommu_cap);
> +
> +	ret = hv_initialize_static_domains();
> +	if (ret)
> +		goto err_free;
[ ... ]
> +err_free:
> +	kfree(hv_iommu);

[Severity: Low]
If hv_iommu_init() fails after calling hv_init_iommu_device(), the allocated
memory is freed here on the err_free path. Does the global pointer
hv_iommu_device need to be reset to NULL to avoid leaving a dangling pointer?

While this might currently be unreachable because functions using
hv_iommu_device are invoked via callbacks that are only registered on
successful init, could this pose a regression risk for future code accessing
this global state?

> +	return ret;
> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260904075512.174154-1-zhangyu1@linux.microsoft.com?part=4

  reply	other threads:[~2026-09-04  8:16 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-04  7:55 [PATCH v5 0/5] Hyper-V: Add para-virtualized IOMMU support for Linux guests Yu Zhang
2026-09-04  7:55 ` [PATCH v5 1/5] hyperv: Introduce new hypercall interfaces used by Hyper-V guest IOMMU Yu Zhang
2026-09-04  8:04   ` sashiko-bot
2026-09-04  7:55 ` [PATCH v5 2/5] Drivers: hv: Add logical device ID registry for vPCI devices Yu Zhang
2026-09-04  8:01   ` sashiko-bot
2026-09-04  7:55 ` [PATCH v5 3/5] iommu/x86: Add architectural MSI reserved region helper Yu Zhang
2026-09-04  8:02   ` sashiko-bot
2026-09-04  7:55 ` [PATCH v5 4/5] iommu/hyperv: Add para-virtualized IOMMU support for Hyper-V guest Yu Zhang
2026-09-04  8:16   ` sashiko-bot [this message]
2026-09-05  2:15   ` Mukesh R
2026-09-07  8:41     ` Yu Zhang
2026-09-07 21:08       ` Mukesh R
2026-09-08  3:16         ` Yu Zhang
2026-09-08 23:44           ` Mukesh R
2026-09-04  7:55 ` [PATCH v5 5/5] iommu/hyperv: Add page-selective IOTLB flush support Yu Zhang
2026-09-04  8:07   ` sashiko-bot
2026-09-04 14:53   ` Michael Kelley
2026-09-07  8:48 ` [PATCH v5 0/5] Hyper-V: Add para-virtualized IOMMU support for Linux guests Yu Zhang

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=20260904081603.74FDB1F00A3D@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.