* [PATCH] vfio/pds: Potential memory leak in pds_vfio_dirty_enable()
@ 2024-01-23 1:13 Cong Liu
2024-01-23 8:35 ` Tian, Kevin
2024-01-23 17:52 ` Brett Creeley
0 siblings, 2 replies; 3+ messages in thread
From: Cong Liu @ 2024-01-23 1:13 UTC (permalink / raw
To: Brett Creeley, Jason Gunthorpe, Yishai Hadas, Shameer Kolothum,
Kevin Tian, Alex Williamson
Cc: Cong Liu, kvm, linux-kernel
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;
+ }
+
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: [PATCH] vfio/pds: Potential memory leak in pds_vfio_dirty_enable()
2024-01-23 1:13 [PATCH] vfio/pds: Potential memory leak in pds_vfio_dirty_enable() Cong Liu
@ 2024-01-23 8:35 ` Tian, Kevin
2024-01-23 17:52 ` Brett Creeley
1 sibling, 0 replies; 3+ messages in thread
From: Tian, Kevin @ 2024-01-23 8:35 UTC (permalink / raw
To: Cong Liu, Brett Creeley, Jason Gunthorpe, Yishai Hadas,
Shameer Kolothum, Alex Williamson
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org
> From: Cong Liu <liucong2@kylinos.cn>
> Sent: Tuesday, January 23, 2024 9:13 AM
>
> the patch releases the region_info memory if the interval_tree_iter_first()
> function fails.
>
> Signed-off-by: Cong Liu <liucong2@kylinos.cn>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] vfio/pds: Potential memory leak in pds_vfio_dirty_enable()
2024-01-23 1:13 [PATCH] vfio/pds: Potential memory leak in pds_vfio_dirty_enable() Cong Liu
2024-01-23 8:35 ` Tian, Kevin
@ 2024-01-23 17:52 ` Brett Creeley
1 sibling, 0 replies; 3+ messages in thread
From: Brett Creeley @ 2024-01-23 17:52 UTC (permalink / raw
To: Cong Liu, Brett Creeley, Jason Gunthorpe, Yishai Hadas,
Shameer Kolothum, Kevin Tian, Alex Williamson
Cc: kvm, linux-kernel
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
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-01-23 17:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-23 1:13 [PATCH] vfio/pds: Potential memory leak in pds_vfio_dirty_enable() Cong Liu
2024-01-23 8:35 ` Tian, Kevin
2024-01-23 17:52 ` Brett Creeley
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).