From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Dumazet Subject: [PATCH net] ipv6: fix possible mem leaks in ipv6_make_skb() Date: Wed, 10 Jan 2018 03:45:49 -0800 Message-ID: <1515584749.131759.21.camel@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit Cc: netdev , Mike Maloney To: Vladislav Yasevich , David Miller Return-path: Received: from mail-io0-f195.google.com ([209.85.223.195]:44232 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933212AbeAJLpy (ORCPT ); Wed, 10 Jan 2018 06:45:54 -0500 Received: by mail-io0-f195.google.com with SMTP id k18so22117660ioc.11 for ; Wed, 10 Jan 2018 03:45:53 -0800 (PST) Sender: netdev-owner@vger.kernel.org List-ID: From: Eric Dumazet ip6_setup_cork() might return an error, while memory allocations have been done and must be rolled back. Fixes: 6422398c2ab0 ("ipv6: introduce ipv6_make_skb") Signed-off-by: Eric Dumazet Cc: Vlad Yasevich Reported-by: Mike Maloney ---  net/ipv6/ip6_output.c |    5 +++--  1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index f7dd51c4231415fd1321fd431194d896ea2d1689..688ba5f7516b37c87b879036dce781bdcfa01739 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c @@ -1735,9 +1735,10 @@ struct sk_buff *ip6_make_skb(struct sock *sk, cork.base.opt = NULL; v6_cork.opt = NULL; err = ip6_setup_cork(sk, &cork, &v6_cork, ipc6, rt, fl6); - if (err) + if (err) { + ip6_cork_release(&cork, &v6_cork); return ERR_PTR(err); - + } if (ipc6->dontfrag < 0) ipc6->dontfrag = inet6_sk(sk)->dontfrag;