Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4373529imw; Tue, 19 Jul 2022 05:34:19 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vH6xMz9SDkR5WsQ+gEkR73ahYh4cf87uM+NGoOfEEgYVbAmFYBulbaSjlcEegHPbV8DVY4 X-Received: by 2002:a05:6402:25c6:b0:43b:7797:d953 with SMTP id x6-20020a05640225c600b0043b7797d953mr3735149edb.254.1658234059272; Tue, 19 Jul 2022 05:34:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658234059; cv=none; d=google.com; s=arc-20160816; b=hx+Nh0MsEB05yycaR9KGZX6ChC5VT1bJY66om182AqPg5Zba8LVzseMLZiil60T8Wq kOFHu9IfSOmog6pz8g45Xj9bo2XRUUgNrpcViXVBHFbrf40QuFmasuePBe9VopQ5U2e2 Ec9NyUiZatKmP1mugDVgIsQYh2V872KKn+WuH3dmf0sWAG2/KmJ0N5cDMzr3pvBcli11 Mr3maJsWXYeQTgCvinnNbqzjmchhlJViKRr+pKFzXxuah+gFonDoQ3MboJwp24c9YYx/ qzIeLcc4lDF1oFBLyzlVraDQBx1KYVismfMTct0eyCrWOCphsqDsRDkg1NmQKQe1F38U Xz1w== 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=pyqO8VFYP59pJE+ogNRpcbDoV5EQwQ3uO4tqYLi4fx8=; b=WbqAn9rKCmQlK4uAU1c/KhJoTAhCb5I3eSpMbTW/HbsPluJ3wpccmPHsMp0OAafNmV NF+iDVmKzO6XFA9WUxY++IBf29YkM75ZRVpriTYLBQ4zXJ6MwSMPLaIylHBS1y62gOVP LuMZxDdmW0fAnTsjoe3kgT9khuBO44OlaBlFBaXBPgSpBWie2waMyNzleKF5LwpmFiQ1 Fz5T9Qns55mAEY3ioverP4WMZl/alhcDwATCg4NjxPjSOzkw9ji26OiLiG1kZ4ntBfeN sgqcA8f19jSYlyOhlRYCbHK0/zsHwMtwwEwrI2NuwgXM80pVzhYHtZdRDsKV6TDSLY9d yMNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="nn/TcH/V"; 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 z21-20020a170906271500b00702d8b7438csi16102919ejc.326.2022.07.19.05.33.53; Tue, 19 Jul 2022 05:34:19 -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="nn/TcH/V"; 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 S238608AbiGSMMf (ORCPT + 99 others); Tue, 19 Jul 2022 08:12:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238792AbiGSMLp (ORCPT ); Tue, 19 Jul 2022 08:11:45 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7DFB95247E; Tue, 19 Jul 2022 05:03:33 -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 B53A0B817AF; Tue, 19 Jul 2022 12:03:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0B8C8C341C6; Tue, 19 Jul 2022 12:03:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658232210; bh=+Tc7B7eHJsJlCG5mleBaegds+TrWSgEsBX0tpPnlfSk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nn/TcH/VZKpxc/Di6gEKP2x9ExHWfF6C9XjDsl5XJq7+u18tPiWyr91rBgnfI5Hp7 XQPv1H40MZsQtOOjjSez9EvwYo+hoQEfbx5lfoeq91Luhkvps1DAAajYOziPfXCzjG HmHSbTvvSfc4O7q2UX9WPmztBukTndU0gUl2uThg= 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.4 50/71] net: tipc: fix possible refcount leak in tipc_sk_create() Date: Tue, 19 Jul 2022 13:54:13 +0200 Message-Id: <20220719114557.177572163@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220719114552.477018590@linuxfoundation.org> References: <20220719114552.477018590@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 d543c4556df2..58c4d61d603f 100644 --- a/net/tipc/socket.c +++ b/net/tipc/socket.c @@ -455,6 +455,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