pciutils/0003-Fix-memory-leak-when-fill-flags-has-PCI_FILL_PARENT.patch

36 lines
806 B
Diff
Raw Normal View History

From 869a9f66b6aa723d9f90b4b3e27cd96bee5e0180 Mon Sep 17 00:00:00 2001
From: nsf.cd <zhaolei4@nsfocus.com>
Date: Fri, 9 Aug 2024 14:06:44 +0800
Subject: [PATCH] Fix memory leak when fill flags has PCI_FILL_PARENT.
---
lib/sysfs.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/lib/sysfs.c b/lib/sysfs.c
index ffa4f9d..135a967 100644
--- a/lib/sysfs.c
+++ b/lib/sysfs.c
@@ -407,12 +407,18 @@ sysfs_fill_info(struct pci_dev *d, unsigned int flags)
path_canon = realpath(path_rel, NULL);
if (!path_canon || strcmp(path_canon, path_abs) != 0)
parent = NULL;
+
+ if (path_canon)
+ free(path_canon);
}
if (parent)
d->parent = parent;
else
clear_fill(d, PCI_FILL_PARENT);
+
+ if (path_abs)
+ free(path_abs);
}
}
--
2.33.0