Skip to contentSkip to conversation

tools: libxencall/foreignmemory: initialise handle->fd

PATCH In review Ian Campbell 2 participants 3 messages Feb 3, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools: libxencall/foreignmemory: initialise handle->fd

Otherwise the osdep close on the error path touches an uninitialised varialble.

CID: 1351231 (foreignmemory) and 1351230 (call)

---
 tools/libs/call/core.c          | 2 ++
 tools/libs/foreignmemory/core.c | 1 +
 2 files changed, 3 insertions(+)
tools/libs/call/core.c +2 -0
index bbf88de..5ca0372 100644
@@ -24,6 +24,8 @@ xencall_handle *xencall_open(xentoollog_logger *logger, unsigned open_flags)
 
     if (!xcall) return NULL;
 
+    xcall->fd = -1;
+
     xcall->flags = open_flags;
     xcall->buffer_cache_nr = 0;
 
tools/libs/foreignmemory/core.c +1 -0
index cfb0a73..6591888 100644
@@ -27,6 +27,7 @@ xenforeignmemory_handle *xenforeignmemory_open(xentoollog_logger *logger,
 
     if (!fmem) return NULL;
 
+    fmem->fd = -1;
     fmem->logger = logger;
     fmem->logger_tofree = NULL;
 
Signature · 1 line
2.1.4
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Ian Campbell

Otherwise the osdep close on the error path touches an uninitialised varialble.

CID: 1351231 (foreignmemory) and 1351230 (call)

Quoted 33 lines
---
 tools/libs/call/core.c          | 2 ++
 tools/libs/foreignmemory/core.c | 1 +
 2 files changed, 3 insertions(+)
tools/libs/call/core.c +2 -0
index bbf88de..5ca0372 100644
@@ -24,6 +24,8 @@ xencall_handle *xencall_open(xentoollog_logger *logger, unsigned open_flags)
 
     if (!xcall) return NULL;
 
+    xcall->fd = -1;
+
     xcall->flags = open_flags;
     xcall->buffer_cache_nr = 0;
 
tools/libs/foreignmemory/core.c +1 -0
index cfb0a73..6591888 100644
@@ -27,6 +27,7 @@ xenforeignmemory_handle *xenforeignmemory_open(xentoollog_logger *logger,
 
     if (!fmem) return NULL;
 
+    fmem->fd = -1;
     fmem->logger = logger;
     fmem->logger_tofree = NULL;
 
Signature · 1 line
2.1.4