From 4cf7e032960a945f813784a68bf0b982a4035bf9 Mon Sep 17 00:00:00 2001 From: Thierry Escande Date: Wed, 10 Jul 2013 10:55:37 +0200 Subject: [PATCH] NFC: rawsock: Fix a memory leak In the rawsock data exchange callback, the sk_buff is not freed on error. Signed-off-by: Thierry Escande Signed-off-by: Samuel Ortiz --- net/nfc/rawsock.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/net/nfc/rawsock.c b/net/nfc/rawsock.c index 313bf1b..cd958b3 100644 --- a/net/nfc/rawsock.c +++ b/net/nfc/rawsock.c @@ -142,11 +142,11 @@ static void rawsock_data_exchange_complete(void *context, struct sk_buff *skb, err = rawsock_add_header(skb); if (err) - goto error; + goto error_skb; err = sock_queue_rcv_skb(sk, skb); if (err) - goto error; + goto error_skb; spin_lock_bh(&sk->sk_write_queue.lock); if (!skb_queue_empty(&sk->sk_write_queue)) @@ -158,6 +158,9 @@ static void rawsock_data_exchange_complete(void *context, struct sk_buff *skb, sock_put(sk); return; +error_skb: + kfree_skb(skb); + error: rawsock_report_error(sk, err); sock_put(sk); -- 2.7.4