Thread (2 messages) flat view 2 messages, 2 authors, 2021-11-16
STALE1773d

[BlueZ PATCH] emulator: fix potential resource leak

From: Tedd Ho-Jeong An <hidden>
Date: 2021-11-16 06:49:52
Subsystem: the rest · Maintainer: Linus Torvalds

From: Tedd Ho-Jeong An <redacted>

This patch releases the allocated fd to prevent the potential resource
leak. This was reported by the Coverity scan.
---
 emulator/vhci.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/emulator/vhci.c b/emulator/vhci.c
index 59ad1ecb8..014df87d2 100644
--- a/emulator/vhci.c
+++ b/emulator/vhci.c
@@ -140,8 +140,10 @@ struct vhci *vhci_open(uint8_t type)
 	}
 
 	vhci = malloc(sizeof(*vhci));
-	if (!vhci)
+	if (!vhci) {
+		close(fd);
 		return NULL;
+	}
 
 	memset(vhci, 0, sizeof(*vhci));
 	vhci->type = type;
-- 
2.25.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help