Commit 5b673d34 authored by phil.turnbull@oracle.com's avatar phil.turnbull@oracle.com Committed by Ben Hutchings

irda: Free skb on irda_accept error path.

commit 8ab86c00 upstream.

skb is not freed if newsk is NULL. Rework the error path so free_skb is
unconditionally called on function exit.

Fixes: c3ea9fa2 ("[IrDA] af_irda: IRDA_ASSERT cleanups")
Signed-off-by: default avatarPhil Turnbull <phil.turnbull@oracle.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
[bwh: Backported to 3.2: adjust context]
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent a289c65c
...@@ -846,7 +846,7 @@ static int irda_accept(struct socket *sock, struct socket *newsock, int flags) ...@@ -846,7 +846,7 @@ static int irda_accept(struct socket *sock, struct socket *newsock, int flags)
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
struct irda_sock *new, *self = irda_sk(sk); struct irda_sock *new, *self = irda_sk(sk);
struct sock *newsk; struct sock *newsk;
struct sk_buff *skb; struct sk_buff *skb = NULL;
int err; int err;
IRDA_DEBUG(2, "%s()\n", __func__); IRDA_DEBUG(2, "%s()\n", __func__);
...@@ -916,7 +916,6 @@ static int irda_accept(struct socket *sock, struct socket *newsock, int flags) ...@@ -916,7 +916,6 @@ static int irda_accept(struct socket *sock, struct socket *newsock, int flags)
err = -EPERM; /* value does not seem to make sense. -arnd */ err = -EPERM; /* value does not seem to make sense. -arnd */
if (!new->tsap) { if (!new->tsap) {
IRDA_DEBUG(0, "%s(), dup failed!\n", __func__); IRDA_DEBUG(0, "%s(), dup failed!\n", __func__);
kfree_skb(skb);
goto out; goto out;
} }
...@@ -935,7 +934,6 @@ static int irda_accept(struct socket *sock, struct socket *newsock, int flags) ...@@ -935,7 +934,6 @@ static int irda_accept(struct socket *sock, struct socket *newsock, int flags)
/* Clean up the original one to keep it in listen state */ /* Clean up the original one to keep it in listen state */
irttp_listen(self->tsap); irttp_listen(self->tsap);
kfree_skb(skb);
sk->sk_ack_backlog--; sk->sk_ack_backlog--;
newsock->state = SS_CONNECTED; newsock->state = SS_CONNECTED;
...@@ -943,6 +941,7 @@ static int irda_accept(struct socket *sock, struct socket *newsock, int flags) ...@@ -943,6 +941,7 @@ static int irda_accept(struct socket *sock, struct socket *newsock, int flags)
irda_connect_response(new); irda_connect_response(new);
err = 0; err = 0;
out: out:
kfree_skb(skb);
release_sock(sk); release_sock(sk);
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment