sysfsutils/0002-lib-Fixed-memory-leaks-in-lib-sysfs_device.c.patch

39 lines
1.1 KiB
Diff
Raw Normal View History

From e2267a5def65380db738e434da4a3920e6136f95 Mon Sep 17 00:00:00 2001
From: Chris White <chwhite@redhat.com>
Date: Fri, 25 Jun 2021 17:55:00 +0000
Subject: [PATCH] lib: Fixed memory leaks in lib/sysfs_device.c
- sysfs_open_device_tree() has two case where the function returns
before the devlist pointer is closed.
Warned-by: covscan
Signed-off-by: Chris White <chwhite@redhat.com>
---
lib/sysfs_device.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/sysfs_device.c b/lib/sysfs_device.c
index 5f815f9..78ed48e 100644
--- a/lib/sysfs_device.c
+++ b/lib/sysfs_device.c
@@ -247,6 +247,7 @@ struct sysfs_device *sysfs_open_device_tree(const char *path)
if (new == NULL) {
dbg_printf("Error opening device tree at %s\n",
cur->path);
+ sysfs_close_device(devlist);
sysfs_close_device_tree(rootdev);
return NULL;
}
@@ -257,7 +258,7 @@ struct sysfs_device *sysfs_open_device_tree(const char *path)
dlist_unshift_sorted(rootdev->children, new, sort_list);
}
}
-
+ sysfs_close_device(devlist);
return rootdev;
}
--
2.27.0