Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4369017imw; Tue, 19 Jul 2022 05:29:21 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s5r77Yxs3Ck1vt58FKAQwd/XtiypxHIOF0Hp1ltQqqnDYx/7z74zQO2/G1PnMV/EdL+Ldx X-Received: by 2002:a17:906:5055:b0:6ff:1dfb:1e2c with SMTP id e21-20020a170906505500b006ff1dfb1e2cmr30487746ejk.200.1658233761161; Tue, 19 Jul 2022 05:29:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658233761; cv=none; d=google.com; s=arc-20160816; b=lS5U9anV+Eqy76oagKGYokaRNZmBuulXQeeP3t48nLOo0Cgf/nhtefZxh5rouvksJi nKCwXeR0bAi6m/YCPVigy6wURn0nA8z8m9rYP/26l5rYG51Zv49AjU5cpOh7s9JfPMky iTYSA8pUqwBDgooJtKz7T1WGEh0NkXgotLXZ8Ix7bwunjAU56A+yja+y/aXN/vP/IKYu mr/Rgj3YO8sr4wvwB92Y951lHtrzX52TbVUk4VSVPgYNdegZ8ivmY4Kzp+p80okAHSsc WLL0Mu/VngCL68IHghLOWzl6ExfjOWubwWbX33CF5zrNPOAsEFg/90v0xmbNAMANfT+j wblQ== 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=4/0Ciif4rwEjChdLUBxw/sLs3cCOxJKYVnPzcyoMe5g=; b=OUHg13k7vdTpVDIJNM4Rb8DGQRs3KhBumSDOq7T/GEXGeRnVNfZ4k2vkGPH/fu2iNl qhMxC0KsCKRNuR7uAMM1bLMo4MsG3OIPBt2onrzOfFl+SOtpBMutVogCCMcWtkUEv6aH y5BReekesdouQrysF1r0tEflUWzjR1MUg0SKHWzP/SeFaSSqRxFE8jkcLlrK61g01MzP 2r2Qvik0w4MY/8VadLzRMLl25uPtCNynIzWTHtBTE/5bcJz14FhqQ89dTwm4Ttzbae/Q eqE7pnSdTVu/jNZWC2qdW63TUHmpk7jACYqv95s0hSkcMSiOyUgw0yB0MiBgEhvl6k7I ARuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NGGnmzMh; 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 hc34-20020a17090716a200b0072edc70deb2si13938262ejc.624.2022.07.19.05.28.55; Tue, 19 Jul 2022 05:29:21 -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=NGGnmzMh; 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 S238363AbiGSMHs (ORCPT + 99 others); Tue, 19 Jul 2022 08:07:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237578AbiGSMHW (ORCPT ); Tue, 19 Jul 2022 08:07:22 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 719724E84F; Tue, 19 Jul 2022 05:01:11 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 88F9A61642; Tue, 19 Jul 2022 12:01:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6D23DC341CA; Tue, 19 Jul 2022 12:01:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658232069; bh=08xxHGUudMtdS1OarUIzc4kUHpP8gjuUZlzB8ABPe2E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NGGnmzMhK2rgj0FXoGKZ4XgS3u0Hn+SOH6hVPy72YF97qWS6cglWagIEDRmOkOWD3 FjOQPJ0HQEt2zqGdFKUR3Fw7bxT6Acahp/rEbwKk4mseNFSx37Rh4vBTCTNdgY1y+e UfJvFlOUFBhTT2o4/jmzRe3N4YAvjgeVNBeh5QgA= 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 4.19 32/48] net: tipc: fix possible refcount leak in tipc_sk_create() Date: Tue, 19 Jul 2022 13:54:09 +0200 Message-Id: <20220719114522.749383754@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220719114518.915546280@linuxfoundation.org> References: <20220719114518.915546280@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 6c18b4565ab5..8266452c143b 100644 --- a/net/tipc/socket.c +++ b/net/tipc/socket.c @@ -453,6 +453,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