[PATCH] open_layer3(): Close file descriptor on error in all cases
Thomas Jarosch <[email protected]> Mon, 08 Sep 2014 11:39:58 +0200
| Newsgroups | gmane.linux.isdn.i4l.user |
|---|---|
| Message-ID | <2410988.osQTECXBBy@storm> |
---
lib/layer3/mlayer3.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/lib/layer3/mlayer3.c b/lib/layer3/mlayer3.c
index eb90d99..eca7b8b 100644
--- a/lib/layer3/mlayer3.c
+++ b/lib/layer3/mlayer3.c
@@ -107,11 +107,14 @@ open_layer3(unsigned int dev, unsigned int proto, unsigned int prop, mlayer3_cb_
/* handle version backward compatibility specific stuff here */
l3 = calloc(1, sizeof(struct _layer3));
- if (!l3)
+ if (!l3) {
+ close(fd);
return NULL;
+ }
l3->ml3.devinfo = calloc(1, sizeof(*l3->ml3.devinfo));
if (!l3->ml3.devinfo) {
free(l3);
+ close(fd);
return NULL;
}
l3->ml3.options = prop;
--
1.9.3