diff mbox

[PATCHv3,01/10] linux-generic: set not initialized socket to -1

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

Commit Message

Maxim Uvarov Dec. 1, 2014, 2:08 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 c523350..acc03bb 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));
+	/* valid socket() might be 0, set not initialized socket to -1 */
+	entry->s.pkt_sock.sockfd = -1;
+	entry->s.pkt_sock_mmap.sockfd = -1;
 }
 
 static odp_pktio_t alloc_lock_pktio_entry(void)