Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4373736imw; Tue, 19 Jul 2022 05:34:33 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sHoM5yKFw7UVFqUyAWzIoF6WqRWfFPLPNxUMqzoTr3OI49dzMV/IGjPe6YrqMAzXu4fdTb X-Received: by 2002:a17:907:d28:b0:72b:5cc9:99c with SMTP id gn40-20020a1709070d2800b0072b5cc9099cmr30508135ejc.228.1658234073665; Tue, 19 Jul 2022 05:34:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658234073; cv=none; d=google.com; s=arc-20160816; b=RzyLxaox+pPtwHnBm9Z56orZUYJ8GU2yaBiGDUvvUR88FyPhh8MgwCvmgZf4SO6Eqa X/EwK1KuwXpMaUoxip/ZoCk4+xQXIVjBPJOMcSQnl/48mJf3aizYy5qfgvJzkhD/OFln eS3rlTof1t9ur4mzu2p/ASg/GM/dGx0qtaOjIZe1om9eX1BipVPSLBURYJqXwogOqtkm yGQLFjIDp8q/pcqG8tMxy14i8b2sF5sHMjQt8W5uF2AfGPqZPMitU0UMtNNfsQZY/y1d pu6curQzJ6ltAyQYkjpTP8y6Ljnhx2lZZ4sfIt34uWG066Nk+69PSXqkZRDaRqUBlmJw QtGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=UivXH4jLWH+4zk/R26HF3hyLLPDjzxmipJptORJ2ABA=; b=CN3ERCi7lPBv5fafBB40qqsdb+35mSUvvzNuWfMvqMf1p90RcIJC6CmIjE6uPzicIB 7xCKs7N8LfpLtijik5W6snCh5aRw4f2TBJ0XMwIawrVqyIq6Mm4t5srDMkzAJexyfY0A olWwlBlxkarqUaBpRWOGwGDRGoOsxhVH5dJlXzT38GXJVBOBPQkQom14gFepuT4coj7C TJmbqc7pioG/nBWHJxdziTJ4mKiJbhcZJ/jpVMtiirMsG27BWPXRnvsTvDsV9OkTAiwM G5ExoVRNlQtAz4KHqV31cur6xvtolOy/aF50zODkfOfBpnMSmpHtbGnKPC/Yk7n49zsB RTyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=SSRclJx4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w9-20020a056402268900b00435b2a66c73si20635222edd.191.2022.07.19.05.34.07; Tue, 19 Jul 2022 05:34:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=SSRclJx4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239562AbiGSM0r (ORCPT + 99 others); Tue, 19 Jul 2022 08:26:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239748AbiGSMYP (ORCPT ); Tue, 19 Jul 2022 08:24:15 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C31A149B78; Tue, 19 Jul 2022 05:09:03 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id E3AA0B817AF; Tue, 19 Jul 2022 12:08:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 43AE5C341C6; Tue, 19 Jul 2022 12:08:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658232513; bh=bAIRwr6BEm+EAGgJYiIeXfINsAsI8XaB6jUr0p/oxfg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SSRclJx4hMyyuq0Xmg+Sn3uW/YXiuB1l/W1GHz4JHyrjICokEEZI5EU2HO0J4Lu04 +0Ovp8GT3hb67K/+67t5lYBDGDhXBAqucmefLDbs6JNmiyWto0szkvIbApPmD3EN/S 2ZUQ384et0GpEm7b1+VKGIB0kPE7iGRcv9EFpqUY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hangyu Hua , Tung Nguyen , "David S. Miller" , Sasha Levin Subject: [PATCH 5.10 083/112] net: tipc: fix possible refcount leak in tipc_sk_create() Date: Tue, 19 Jul 2022 13:54:16 +0200 Message-Id: <20220719114634.643674414@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220719114626.156073229@linuxfoundation.org> References: <20220719114626.156073229@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hangyu Hua [ Upstream commit 00aff3590fc0a73bddd3b743863c14e76fd35c0c ] Free sk in case tipc_sk_insert() fails. Signed-off-by: Hangyu Hua Reviewed-by: Tung Nguyen Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/tipc/socket.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/tipc/socket.c b/net/tipc/socket.c index 42283dc6c5b7..38256aabf4f1 100644 --- a/net/tipc/socket.c +++ b/net/tipc/socket.c @@ -489,6 +489,7 @@ static int tipc_sk_create(struct net *net, struct socket *sock, sock_init_data(sock, sk); tipc_set_sk_state(sk, TIPC_OPEN); if (tipc_sk_insert(tsk)) { + sk_free(sk); pr_warn("Socket create failed; port number exhausted\n"); return -EINVAL; } -- 2.35.1