diff mbox

[PATCHv4,1/6] linux-generic: set not initialized socket to -1

Message ID 1417619157-13690-2-git-send-email-maxim.uvarov@linaro.org
State New
Headers show

Commit Message

Maxim Uvarov Dec. 3, 2014, 3:05 p.m. UTC
In case of stdin is not attached socket() can return 0 for valid
socket fd. Not initialized socket has to be -1.

Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
---
 platform/linux-generic/odp_packet_io.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox

Patch

diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c
index 706a3cc..faa197f 100644
--- a/platform/linux-generic/odp_packet_io.c
+++ b/platform/linux-generic/odp_packet_io.c
@@ -114,6 +114,9 @@  static void init_pktio_entry(pktio_entry_t *entry)
 	entry->s.inq_default = ODP_QUEUE_INVALID;
 	memset(&entry->s.pkt_sock, 0, sizeof(entry->s.pkt_sock));
 	memset(&entry->s.pkt_sock_mmap, 0, sizeof(entry->s.pkt_sock_mmap));
+	/* set sockfd to -1, because a valid socked might be initialized to 0 */
+	entry->s.pkt_sock.sockfd = -1;
+	entry->s.pkt_sock_mmap.sockfd = -1;
 }
 
 static odp_pktio_t alloc_lock_pktio_entry(void)