From: "Creeley, Brett" <bcreeley@amd.com>
To: Zilin Guan <zilin@seu.edu.cn>, jgg@ziepe.ca
Cc: yishaih@nvidia.com, skolothumtho@nvidia.com,
kevin.tian@intel.com, brett.creeley@amd.com, alex@shazbot.org,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
jianhao.xu@seu.edu.cn
Subject: Re: [PATCH] vfio/pds: Fix memory leak in pds_vfio_dirty_enable()
Date: Mon, 5 Jan 2026 09:38:54 -0800 [thread overview]
Message-ID: <86de1961-8d1c-465a-b822-0dd7cb094d46@amd.com> (raw)
In-Reply-To: <20251225143150.1117366-1-zilin@seu.edu.cn>
On 12/25/2025 6:31 AM, Zilin Guan wrote:
> Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
>
>
> pds_vfio_dirty_enable() allocates memory for region_info. If
> interval_tree_iter_first() returns NULL, the function returns -EINVAL
> immediately without freeing the allocated memory, causing a memory leak.
>
> Fix this by jumping to the out_free_region_info label to ensure
> region_info is freed.
>
> Fixes: 2e7c6feb4ef52 ("vfio/pds: Add multi-region support")
> Signed-off-by: Zilin Guan <zilin@seu.edu.cn>
> ---
> drivers/vfio/pci/pds/dirty.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/vfio/pci/pds/dirty.c b/drivers/vfio/pci/pds/dirty.c
> index 481992142f79..4915a7c1c491 100644
> --- a/drivers/vfio/pci/pds/dirty.c
> +++ b/drivers/vfio/pci/pds/dirty.c
> @@ -292,8 +292,11 @@ static int pds_vfio_dirty_enable(struct pds_vfio_pci_device *pds_vfio,
> len = num_ranges * sizeof(*region_info);
>
> node = interval_tree_iter_first(ranges, 0, ULONG_MAX);
> - if (!node)
> - return -EINVAL;
> + if (!node) {
> + err = -EINVAL;
> + goto out_free_region_info;
> + }
> +
Thanks for the fix. I was on vacation, but FWIW:
Reviewed-by: Brett Creeley <brett.creeley@amd.com>
> for (int i = 0; i < num_ranges; i++) {
> struct pds_lm_dirty_region_info *ri = ®ion_info[i];
> u64 region_size = node->last - node->start + 1;
> --
> 2.34.1
>
prev parent reply other threads:[~2026-01-05 17:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-25 14:31 Zilin Guan
2025-12-28 20:47 ` Alex Williamson
2026-01-05 17:38 ` Creeley, Brett [this message]
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=86de1961-8d1c-465a-b822-0dd7cb094d46@amd.com \
--to=bcreeley@amd.com \
--cc=alex@shazbot.org \
--cc=brett.creeley@amd.com \
--cc=jgg@ziepe.ca \
--cc=jianhao.xu@seu.edu.cn \
--cc=kevin.tian@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=skolothumtho@nvidia.com \
--cc=yishaih@nvidia.com \
--cc=zilin@seu.edu.cn \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®