From: Brett Creeley <bcreeley@amd.com>
To: Cong Liu <liucong2@kylinos.cn>,
Brett Creeley <brett.creeley@amd.com>,
Jason Gunthorpe <jgg@ziepe.ca>, Yishai Hadas <yishaih@nvidia.com>,
Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>,
Kevin Tian <kevin.tian@intel.com>,
Alex Williamson <alex.williamson@redhat.com>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] vfio/pds: Potential memory leak in pds_vfio_dirty_enable()
Date: Tue, 23 Jan 2024 09:52:51 -0800 [thread overview]
Message-ID: <2f8c0dfd-5d3a-4135-9d8e-09091fdf87eb@amd.com> (raw)
In-Reply-To: <20240123011319.6954-1-liucong2@kylinos.cn>
On 1/22/2024 5:13 PM, Cong Liu wrote:
> Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
>
>
> the patch releases the region_info memory if the interval_tree_iter_first()
> function fails.
>
> Signed-off-by: Cong Liu <liucong2@kylinos.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 8ddf4346fcd5..67919b5db127 100644
> --- a/drivers/vfio/pci/pds/dirty.c
> +++ b/drivers/vfio/pci/pds/dirty.c
> @@ -291,8 +291,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;
> + }
> +
LGTM! Thanks for fixing this.
Reviewed-by: <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:[~2024-01-23 17:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-23 1:13 Cong Liu
2024-01-23 8:35 ` Tian, Kevin
2024-01-23 17:52 ` Brett Creeley [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=2f8c0dfd-5d3a-4135-9d8e-09091fdf87eb@amd.com \
--to=bcreeley@amd.com \
--cc=alex.williamson@redhat.com \
--cc=brett.creeley@amd.com \
--cc=jgg@ziepe.ca \
--cc=kevin.tian@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liucong2@kylinos.cn \
--cc=shameerali.kolothum.thodi@huawei.com \
--cc=yishaih@nvidia.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 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®