5544c1b
From b88c1cb2b263de9ffc3dcaa2822ef7b1fbd8575a Mon Sep 17 00:00:00 2001
5544c1b
From: Stefan Weil <sw@weilnetz.de>
5544c1b
Date: Tue, 4 Sep 2012 23:20:36 +0200
5544c1b
Subject: [PATCH] slirp: Fix error reported by static code analysis
5544c1b
5544c1b
Report from smatch:
5544c1b
5544c1b
slirp/tcp_subr.c:127 tcp_respond(17) error:
5544c1b
 we previously assumed 'tp' could be null (see line 124)
5544c1b
5544c1b
Return if 'tp' is NULL.
5544c1b
5544c1b
Signed-off-by: Stefan Weil <sw@weilnetz.de>
5544c1b
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
5544c1b
(cherry picked from commit e56afbc54a2132c56931f44bae1992c28119944f)
5544c1b
5544c1b
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
5544c1b
---
5544c1b
 slirp/tcp_subr.c | 2 +-
5544c1b
 1 file changed, 1 insertion(+), 1 deletion(-)
5544c1b
5544c1b
diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c
5544c1b
index 5890d7a..1542e43 100644
5544c1b
--- a/slirp/tcp_subr.c
5544c1b
+++ b/slirp/tcp_subr.c
5544c1b
@@ -124,7 +124,7 @@ tcp_respond(struct tcpcb *tp, struct tcpiphdr *ti, struct mbuf *m,
5544c1b
 	if (tp)
5544c1b
 		win = sbspace(&tp->t_socket->so_rcv);
5544c1b
         if (m == NULL) {
5544c1b
-		if ((m = m_get(tp->t_socket->slirp)) == NULL)
5544c1b
+		if (!tp || (m = m_get(tp->t_socket->slirp)) == NULL)
5544c1b
 			return;
5544c1b
 		tlen = 0;
5544c1b
 		m->m_data += IF_MAXLINKHDR;