Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp233740rwb; Tue, 25 Jul 2023 15:04:09 -0700 (PDT) X-Google-Smtp-Source: APBJJlEUImbVLylTwj2SGYOrwZDtGZLzwq/X7qjvFIzBEPo0wvDM373q6wudJ+Vk8QxO4a60Gl8j X-Received: by 2002:a17:90b:4f92:b0:267:75ce:f6d9 with SMTP id qe18-20020a17090b4f9200b0026775cef6d9mr366139pjb.3.1690322648978; Tue, 25 Jul 2023 15:04:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690322648; cv=none; d=google.com; s=arc-20160816; b=uwxih5HHDQOgkYPEeG7nNQXO5+OgUJJ/1jZXd0Ere/WCmgad66aqPWeLBjgLk8C4yY nydFl4sd1vSSHt+RDPQOlanbIEa4zU2neyDTMzJtWTCQ8p53fJ3zr5eZ20kMbY1inbkN VHVgy/t+736hhRdEvuB3DF8R09UTeaF6p7QIRBtHJKZNMQ5+p2dItzx+G4KqwkMu9GHb K+JO824VmfwIiSrFrOmwUBbLl7df5wIvmTc+cZ8q82HVaHZUqRtpKsrIaJdNbFJOvton J1e9bAxKKIneIxxBLJETx/3X48ak0PSHnnLMvgghcdb35gspUc5ZqKNsZ8wN/ScRjcoa hD+A== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=wQZ+lrRE3oQnyK31lwk/xK6Rt/iFePrIWTkSITlap1w=; fh=XbsocgPLcvDfwU+Z0mwjleoObAujf/3zPtX8MXqfgy8=; b=BTjkRNa/uLqdFtnQ53E4da/Iwbs4O0KTQviVvsZCYs2R5irpvRpwroYv+ZR+GjjbjM 0uuA41TdZPpmztviOIRjxiMT577vcIZtKP/vIkJMpBpBe/EGwx6w/zk2QYl8eArvpZnn 2C+EolF8R35/Lp5BjTUo7DZLSWHTA+zJ3HB38UTGq1rgAAcS+LoQULofzaVHLUuUfL1c kuIwCKpTTwTAl00hVUNY3q17gtSJdbY7IE+XBuTsYNI/JLRbItys7Sq3wF+VN03nxiWL fs5LlGA641z3VP7C0DMUHice6bIquuQZSaj2Kfk/B72wdXoiCKu4d4aPxuvM8vg6L3y4 J5QQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ispras.ru header.s=default header.b="IapLk/Wz"; 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=ispras.ru Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 5-20020a17090a0f8500b00267ed8359e2si101865pjz.55.2023.07.25.15.03.56; Tue, 25 Jul 2023 15:04:08 -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=@ispras.ru header.s=default header.b="IapLk/Wz"; 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=ispras.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231134AbjGYVqv (ORCPT + 99 others); Tue, 25 Jul 2023 17:46:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229448AbjGYVqu (ORCPT ); Tue, 25 Jul 2023 17:46:50 -0400 Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E3B81FDD; Tue, 25 Jul 2023 14:46:49 -0700 (PDT) Received: from localhost.localdomain (unknown [46.242.14.200]) by mail.ispras.ru (Postfix) with ESMTPSA id 3EF0A40737C9; Tue, 25 Jul 2023 21:46:47 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru 3EF0A40737C9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ispras.ru; s=default; t=1690321607; bh=wQZ+lrRE3oQnyK31lwk/xK6Rt/iFePrIWTkSITlap1w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IapLk/WzMzB0LeUX1/U399YIXAH67f1o/o+ul/kZh3sDQszDWnGpRnvWqMQitoDL6 rj47I66xhQJk/BzORiThu7kwqOF2Hp1ocIhjFxYqINMdRypPVgFMQ8mZHN+u8TQ3c1 T15pDjqUfi8l/5xtFokIbvL0i7JzGS8LmNwODVRk= From: Fedor Pchelkin To: Jon Maloy Cc: Fedor Pchelkin , Ying Xue , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Xin Long , netdev@vger.kernel.org, tipc-discussion@lists.sourceforge.net, linux-kernel@vger.kernel.org, Alexey Khoroshilov , lvc-project@linuxtesting.org Subject: [PATCH v2] tipc: stop tipc crypto on failure in tipc_node_create Date: Wed, 26 Jul 2023 00:46:25 +0300 Message-ID: <20230725214628.25246-1-pchelkin@ispras.ru> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 If tipc_link_bc_create() fails inside tipc_node_create() for a newly allocated tipc node then we should stop its tipc crypto and free the resources allocated with a call to tipc_crypto_start(). As the node ref is initialized to one to that point, just put the ref on tipc_link_bc_create() error case that would lead to tipc_node_free() be eventually executed and properly clean the node and its crypto resources. Found by Linux Verification Center (linuxtesting.org). Fixes: cb8092d70a6f ("tipc: move bc link creation back to tipc_node_create") Suggested-by: Xin Long Signed-off-by: Fedor Pchelkin --- v1->v2: simplify the patch per Xin Long's advice: putting the ref on error case would solve the problem more conveniently; update the patch description accordingly. net/tipc/node.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/tipc/node.c b/net/tipc/node.c index 5e000fde8067..a9c5b6594889 100644 --- a/net/tipc/node.c +++ b/net/tipc/node.c @@ -583,7 +583,7 @@ struct tipc_node *tipc_node_create(struct net *net, u32 addr, u8 *peer_id, n->capabilities, &n->bc_entry.inputq1, &n->bc_entry.namedq, snd_l, &n->bc_entry.link)) { pr_warn("Broadcast rcv link creation failed, no memory\n"); - kfree(n); + tipc_node_put(n); n = NULL; goto exit; } -- 2.41.0