summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-08-06 07:42:20 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-08-06 07:42:20 +0000
commit5620a17b53a74e60d97845dadb1e2ac7038b0643 (patch)
tree015057ba7a4a96e3c7bf203ce9597db85836bd52
parentReleasing debian version 1.5-1. (diff)
downloadlibnvme-5620a17b53a74e60d97845dadb1e2ac7038b0643.tar.xz
libnvme-5620a17b53a74e60d97845dadb1e2ac7038b0643.zip
Adding patch from upstream to fix fd leaks with /sys/bus/pci/slots (Closes: #1043095).
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
-rw-r--r--debian/patches/series1
-rw-r--r--debian/patches/upstream/0001-pci-slots-fd-leak.patch26
2 files changed, 27 insertions, 0 deletions
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..08dea8e
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1 @@
+upstream/0001-pci-slots-fd-leak.patch
diff --git a/debian/patches/upstream/0001-pci-slots-fd-leak.patch b/debian/patches/upstream/0001-pci-slots-fd-leak.patch
new file mode 100644
index 0000000..e3a5b15
--- /dev/null
+++ b/debian/patches/upstream/0001-pci-slots-fd-leak.patch
@@ -0,0 +1,26 @@
+Author: Martin Belanger <martin.belanger@dell.com>
+Description: 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.
+
+diff -Naurp libnvme.orig/src/nvme/tree.c libnvme/src/nvme/tree.c
+--- libnvme.orig/src/nvme/tree.c
++++ libnvme/src/nvme/tree.c
+@@ -1292,6 +1292,8 @@ static char *nvme_ctrl_lookup_phy_slot(n
+ 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(n
+ }
+ }
+ free(target_addr);
++ closedir(slots_dir);
+ if (found)
+ return strdup(entry->d_name);
+ return NULL;