mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-10 06:26:57 +02:00
sys-libs/libnvme: Sync with Gentoo
It's from Gentoo commit d1288e2fe17adb3dacd2ab3f1b415c4ed45136d4.
This commit is contained in:
parent
93dd0285c1
commit
1ec15bf254
@ -0,0 +1,36 @@
|
||||
From c56910f807795528fff7ba6b81f8efcdb4babe98 Mon Sep 17 00:00:00 2001
|
||||
From: Martin Belanger <martin.belanger@dell.com>
|
||||
Date: Wed, 5 Jul 2023 10:59:25 -0400
|
||||
Subject: [PATCH] tree: missing closedir() causes fd leak for
|
||||
"/sys/bus/pci/slots"
|
||||
|
||||
In nvme_ctrl_lookup_phy_slot(), we are missing a closedir(), which
|
||||
causes file descriptors to leak. Also, there was a missing free()
|
||||
when the function returns with ENOMEM.
|
||||
|
||||
Signed-off-by: Martin Belanger <martin.belanger@dell.com>
|
||||
---
|
||||
src/nvme/tree.c | 3 +++
|
||||
1 file changed, 3 insertions(+)
|
||||
|
||||
diff --git a/src/nvme/tree.c b/src/nvme/tree.c
|
||||
index a2ac0698..805eff99 100644
|
||||
--- a/src/nvme/tree.c
|
||||
+++ b/src/nvme/tree.c
|
||||
@@ -1292,6 +1292,8 @@ static char *nvme_ctrl_lookup_phy_slot(nvme_root_t r, const char *address)
|
||||
ret = asprintf(&path, "/sys/bus/pci/slots/%s", entry->d_name);
|
||||
if (ret < 0) {
|
||||
errno = ENOMEM;
|
||||
+ free(target_addr);
|
||||
+ closedir(slots_dir);
|
||||
return NULL;
|
||||
}
|
||||
addr = nvme_get_attr(path, "address");
|
||||
@@ -1306,6 +1308,7 @@ static char *nvme_ctrl_lookup_phy_slot(nvme_root_t r, const char *address)
|
||||
}
|
||||
}
|
||||
free(target_addr);
|
||||
+ closedir(slots_dir);
|
||||
if (found)
|
||||
return strdup(entry->d_name);
|
||||
return NULL;
|
@ -28,16 +28,18 @@ DEPEND="
|
||||
uuid? ( sys-apps/util-linux:= )
|
||||
"
|
||||
RDEPEND="${DEPEND}"
|
||||
|
||||
BDEPEND="
|
||||
dev-lang/swig
|
||||
"
|
||||
|
||||
PATCHES=( "${FILESDIR}/${P}-free-segfault.patch" )
|
||||
|
||||
src_configure() {
|
||||
local emesonargs=(
|
||||
-Dpython=false
|
||||
$(meson_feature json json-c)
|
||||
$(meson_feature dbus libdbus)
|
||||
$(meson_feature keyutils)
|
||||
$(meson_feature ssl openssl)
|
||||
$(meson_feature python)
|
||||
)
|
Loading…
Reference in New Issue
Block a user