diff mbox

[2/2] slirp: Fix error reported by static code analysis

Message ID 1346793636-23689-3-git-send-email-sw@weilnetz.de
State Accepted
Headers show

Commit Message

Stefan Weil Sept. 4, 2012, 9:20 p.m. UTC
Report from smatch:

slirp/tcp_subr.c:127 tcp_respond(17) error:
 we previously assumed 'tp' could be null (see line 124)

Return if 'tp' is NULL.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
 slirp/tcp_subr.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jan Kiszka Sept. 5, 2012, 10:47 a.m. UTC | #1
On 2012-09-04 23:20, Stefan Weil wrote:
> Report from smatch:
> 
> slirp/tcp_subr.c:127 tcp_respond(17) error:
>  we previously assumed 'tp' could be null (see line 124)
> 
> Return if 'tp' is NULL.
> 
> Signed-off-by: Stefan Weil <sw@weilnetz.de>
> ---
>  slirp/tcp_subr.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c
> index 5890d7a..1542e43 100644
> --- a/slirp/tcp_subr.c
> +++ b/slirp/tcp_subr.c
> @@ -124,7 +124,7 @@ tcp_respond(struct tcpcb *tp, struct tcpiphdr *ti, struct mbuf *m,
>  	if (tp)
>  		win = sbspace(&tp->t_socket->so_rcv);
>          if (m == NULL) {
> -		if ((m = m_get(tp->t_socket->slirp)) == NULL)
> +		if (!tp || (m = m_get(tp->t_socket->slirp)) == NULL)
>  			return;
>  		tlen = 0;
>  		m->m_data += IF_MAXLINKHDR;
> 

I suppose this is also stable material, therefore extending CC.

Jan
diff mbox

Patch

diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c
index 5890d7a..1542e43 100644
--- a/slirp/tcp_subr.c
+++ b/slirp/tcp_subr.c
@@ -124,7 +124,7 @@  tcp_respond(struct tcpcb *tp, struct tcpiphdr *ti, struct mbuf *m,
 	if (tp)
 		win = sbspace(&tp->t_socket->so_rcv);
         if (m == NULL) {
-		if ((m = m_get(tp->t_socket->slirp)) == NULL)
+		if (!tp || (m = m_get(tp->t_socket->slirp)) == NULL)
 			return;
 		tlen = 0;
 		m->m_data += IF_MAXLINKHDR;