Skip to contentSkip to conversation

lib/cobalt: Fix possible fd leak in __map_umm

PATCH Applied Florian Bezdeka 2 participants 2 messages Apr 19, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib/cobalt: Fix possible fd leak in __map_umm

In case the MEMDEV_RTIOC_STAT fails we have to close the file descriptor.

---

Note: This patch applies to all stable branches as well.

 lib/cobalt/umm.c | 1 +
 1 file changed, 1 insertion(+)
lib/cobalt/umm.c +1 -0
index 944620fee..c30ada6a2 100644
@@ -59,6 +59,7 @@ static void *__map_umm(const char *name, uint32_t *size_r)
 
 	ret = __RT(ioctl(fd, MEMDEV_RTIOC_STAT, &statbuf));
 	if (ret) {
+		__RT(close(fd));
 		early_warning("failed getting status of %s: %s",
 			      name, strerror(errno));
 		return MAP_FAILED;
Signature · 1 line
2.39.2
Applied
#1 lore raw
Quoted 16 lines · Florian Bezdeka

In case the MEMDEV_RTIOC_STAT fails we have to close the file descriptor.

---

Note: This patch applies to all stable branches as well.

 lib/cobalt/umm.c | 1 +
 1 file changed, 1 insertion(+)
lib/cobalt/umm.c +0 -0
index 944620fee..c30ada6a2 100644

lib/cobalt/umm.c static void *__map_umm(const char *name, uint32_t *size_r) · line 65

Quoted 7 lines
lib/cobalt/umm.c +1 -0
@@ -59,6 +59,7 @@ static void *__map_umm(const char *name, uint32_t *size_r)
 
 	ret = __RT(ioctl(fd, MEMDEV_RTIOC_STAT, &statbuf));
 	if (ret) {
+		__RT(close(fd));
 		early_warning("failed getting status of %s: %s",
 			      name, strerror(errno));
 		return MAP_FAILED;

Thanks, applied.

Jan

Signature · 2 lines
Siemens AG, Technology
Competence Center Embedded Linux