[PATCH 01/11] net/enetfec: fix file descriptor leak on read error
Hemant Agrawal
hemant.agrawal at nxp.com
Mon Oct 6 10:04:00 CEST 2025
The file descriptor was not closed when a read error occurred while
reading the first line from a UIO device file. This could lead to
resource leakage. The patch ensures the descriptor is closed in
case of read failure.
Fixes: b84fdd39638b ("net/enetfec: support UIO")
Cc: stable at dpdk.org
Signed-off-by: Hemant Agrawal <hemant.agrawal at nxp.com>
---
drivers/net/enetfec/enet_uio.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/net/enetfec/enet_uio.c b/drivers/net/enetfec/enet_uio.c
index 9f4e896985..23cb4e7e93 100644
--- a/drivers/net/enetfec/enet_uio.c
+++ b/drivers/net/enetfec/enet_uio.c
@@ -1,5 +1,5 @@
/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright 2021 NXP
+ * Copyright 2021,2024 NXP
*/
#include <stdbool.h>
@@ -66,13 +66,16 @@ file_read_first_line(const char root[], const char subdir[],
"%s/%s/%s", root, subdir, filename);
fd = open(absolute_file_name, O_RDONLY);
- if (fd <= 0)
+ if (fd < 0) {
ENETFEC_PMD_ERR("Error opening file %s", absolute_file_name);
+ return fd;
+ }
/* read UIO device name from first line in file */
ret = read(fd, line, FEC_UIO_MAX_DEVICE_FILE_NAME_LENGTH);
if (ret <= 0) {
ENETFEC_PMD_ERR("Error reading file %s", absolute_file_name);
+ close(fd);
return ret;
}
close(fd);
--
2.25.1
More information about the stable
mailing list