From cd75edf25dddd755c63a07cf6387544ccae274f7 Mon Sep 17 00:00:00 2001 From: Qliangw Date: Wed, 27 May 2026 16:37:00 +0800 Subject: [PATCH] libuio: fix FILE descriptor leak The function uio_line_from_file() fails to close the FILE pointer when fgets() returns NULL, causing a file descriptor leak. This can be triggered when reading from /sys files that return empty content, leading to resource exhaustion over time. Fix this by using goto-based error handling to ensure fclose() is called on all exit paths. Signed-off-by: Qliangw --- ...ix-fclose-leak-in-uio_line_from_file.patch | 31 +++++++++++++++++++ .../recipes-extended/libuio/libuio_0.2.1.bb | 1 + 2 files changed, 32 insertions(+) create mode 100644 meta-oe/recipes-extended/libuio/libuio/fix-fclose-leak-in-uio_line_from_file.patch diff --git a/meta-oe/recipes-extended/libuio/libuio/fix-fclose-leak-in-uio_line_from_file.patch b/meta-oe/recipes-extended/libuio/libuio/fix-fclose-leak-in-uio_line_from_file.patch new file mode 100644 index 0000000000..22c6324950 --- /dev/null +++ b/meta-oe/recipes-extended/libuio/libuio/fix-fclose-leak-in-uio_line_from_file.patch @@ -0,0 +1,31 @@ +From: Jason Smith +Subject: [PATCH] Fix FILE descriptor leak in uio_line_from_file() + +The function uio_line_from_file() fails to close the FILE pointer +when fgets() returns NULL, causing a file descriptor leak. + +Upstream-Status: Submitted [https://sourceforge.net/p/libuio/code/merge-requests/2/] +Signed-off-by: Jason Smith + +--- a/src/uio_line_from_file.c ++++ b/src/uio_line_from_file.c +@@ -28,14 +28,17 @@ + { + char *s; + int i; ++ int ret = 0; + memset(linebuf, 0, UIO_MAX_NAME_SIZE); + FILE* file = fopen(filename,"r"); + if (!file) return -1; + s = fgets(linebuf,UIO_MAX_NAME_SIZE,file); +- if (!s) return -2; ++ if (!s) { ret = -2; goto out; } + for (i=0; (*s)&&(i