[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240123011319.6954-1-liucong2@kylinos.cn>
Date: Tue, 23 Jan 2024 09:13:19 +0800
From: Cong Liu <liucong2@...inos.cn>
To: Brett Creeley <brett.creeley@....com>,
Jason Gunthorpe <jgg@...pe.ca>,
Yishai Hadas <yishaih@...dia.com>,
Shameer Kolothum <shameerali.kolothum.thodi@...wei.com>,
Kevin Tian <kevin.tian@...el.com>,
Alex Williamson <alex.williamson@...hat.com>
Cc: Cong Liu <liucong2@...inos.cn>,
kvm@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH] vfio/pds: Potential memory leak in pds_vfio_dirty_enable()
the patch releases the region_info memory if the interval_tree_iter_first()
function fails.
Signed-off-by: Cong Liu <liucong2@...inos.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
Powered by blists - more mailing lists