diff options
author | phil.turnbull@oracle.com <phil.turnbull@oracle.com> | 2016-09-15 12:41:44 -0400 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2016-11-20 01:17:32 +0000 |
commit | dab8025346d3066c7a68111df42239d887e7d0c3 (patch) | |
tree | 91cbbe1ba6d574c34cafdfc67687e556844545b8 | |
parent | c57640556886c9e903d189184eae288b8ee9fca5 (diff) | |
download | lwn-dab8025346d3066c7a68111df42239d887e7d0c3.tar.gz lwn-dab8025346d3066c7a68111df42239d887e7d0c3.zip |
irda: Free skb on irda_accept error path.
commit 8ab86c00e349cef9fb14719093a7f198bcc72629 upstream.
skb is not freed if newsk is NULL. Rework the error path so free_skb is
unconditionally called on function exit.
Fixes: c3ea9fa27413 ("[IrDA] af_irda: IRDA_ASSERT cleanups")
Signed-off-by: Phil Turnbull <phil.turnbull@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
[bwh: Backported to 3.16: adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
-rw-r--r-- | net/irda/af_irda.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/net/irda/af_irda.c b/net/irda/af_irda.c index 033a7af5914e..a34379892d85 100644 --- a/net/irda/af_irda.c +++ b/net/irda/af_irda.c @@ -843,7 +843,7 @@ static int irda_accept(struct socket *sock, struct socket *newsock, int flags) struct sock *sk = sock->sk; struct irda_sock *new, *self = irda_sk(sk); struct sock *newsk; - struct sk_buff *skb; + struct sk_buff *skb = NULL; int err; IRDA_DEBUG(2, "%s()\n", __func__); @@ -913,7 +913,6 @@ static int irda_accept(struct socket *sock, struct socket *newsock, int flags) err = -EPERM; /* value does not seem to make sense. -arnd */ if (!new->tsap) { IRDA_DEBUG(0, "%s(), dup failed!\n", __func__); - kfree_skb(skb); goto out; } @@ -932,7 +931,6 @@ static int irda_accept(struct socket *sock, struct socket *newsock, int flags) /* Clean up the original one to keep it in listen state */ irttp_listen(self->tsap); - kfree_skb(skb); sk->sk_ack_backlog--; newsock->state = SS_CONNECTED; @@ -940,6 +938,7 @@ static int irda_accept(struct socket *sock, struct socket *newsock, int flags) irda_connect_response(new); err = 0; out: + kfree_skb(skb); release_sock(sk); return err; } |