Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp10078944rwb; Fri, 25 Nov 2022 00:20:43 -0800 (PST) X-Google-Smtp-Source: AA0mqf7YRMzta3Udg4eXPJodlghEBGqAhepvyk9uKqpGZ/RD/4LpiHUqBnNWpWyF5vVqoxhw3EUJ X-Received: by 2002:aa7:dbc7:0:b0:45f:b80f:1fe8 with SMTP id v7-20020aa7dbc7000000b0045fb80f1fe8mr32467873edt.118.1669364443430; Fri, 25 Nov 2022 00:20:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669364443; cv=none; d=google.com; s=arc-20160816; b=r+rP2Xrq07fCbxS4n4byNwug7Z8ciNG1u2goA3HYI/jJP5VlHGWyFSUM6cF4Ogr4Lg obQqEdWvTOX2rBD9Kadzk93giiJpZPu13zv0W5hOCCbM4Tc49RO90HmH4rPvqJVhvPnq j9suoh5NFYdIvqWkHr1mLqS7LQZOH5cC6hT9xoi8tz6Klq4FVNnk8EH6IprbmdiRTRGS ynsJ3SCWGSkat1Y+X4+WTr6ynDvl/H11xfT+XrDFt9KHLTm9WTk2wI0vsfdXPJX6nKgS RmtGqDouvcPc0wCkaOhjf65cPTBa7DJp6QijXFuzRJpJGAUcUBsUF8AUFnLX32sD8t4a lR3g== 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; bh=utU1i7epSHSKxUXo4J7TBTpiec02A9F+RuIbuiz1zlM=; b=U/NpHN/viZieBsN3qZfflL4+GYB0Gp5RZQ+AVCbdXHPGqPxNkR0X3sQw8qGGdkoK2w AWPxdPpwcRKPCh9SYKeqYgqgFN7hJBnQFYMRhRKN/L7DLqAjyKGWDvoMkA4zzOJKWAI0 6EJBX6A9aA5QzgskP9fcZrylxewoKj+VOoi/ic6s3bNKkKGhVJZJcuvxvx5FAc+zPwjY ACy0Og09AOhMFjv4GCRTXMZq7I6sX385UiB8aKn9QG6e4RMl4qDs3ctv4mUoAAdTlSpk N8ETozAJ1NB72aO8fn/Uc8trBERiVDaOX9M3AiRN4FgaKrUL3hc7bPWdL82e9z0sEEri 7lvw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hr40-20020a1709073fa800b007417040d1c5si3016779ejc.823.2022.11.25.00.20.22; Fri, 25 Nov 2022 00:20:43 -0800 (PST) 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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229653AbiKYHph (ORCPT + 87 others); Fri, 25 Nov 2022 02:45:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229476AbiKYHpg (ORCPT ); Fri, 25 Nov 2022 02:45:36 -0500 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A67622EF07; Thu, 24 Nov 2022 23:45:35 -0800 (PST) Received: from canpemm500006.china.huawei.com (unknown [172.30.72.55]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4NJRdz5jMPzJnwM; Fri, 25 Nov 2022 15:42:15 +0800 (CST) Received: from localhost.localdomain (10.175.104.82) by canpemm500006.china.huawei.com (7.192.105.130) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 25 Nov 2022 15:45:33 +0800 From: Ziyang Xuan To: , , , , , , , , CC: Subject: [PATCH net 1/2] octeontx2-pf: Fix potential memory leak in otx2_init_tc() Date: Fri, 25 Nov 2022 15:45:30 +0800 Message-ID: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.104.82] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To canpemm500006.china.huawei.com (7.192.105.130) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, 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 In otx2_init_tc(), if rhashtable_init() failed, it does not free tc->tc_entries_bitmap which is allocated in otx2_tc_alloc_ent_bitmap(). Fixes: 2e2a8126ffac ("octeontx2-pf: Unify flow management variables") Signed-off-by: Ziyang Xuan --- drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c index e64318c110fd..6a01ab1a6e6f 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c @@ -1134,7 +1134,12 @@ int otx2_init_tc(struct otx2_nic *nic) return err; tc->flow_ht_params = tc_flow_ht_params; - return rhashtable_init(&tc->flow_table, &tc->flow_ht_params); + err = rhashtable_init(&tc->flow_table, &tc->flow_ht_params); + if (err) { + kfree(tc->tc_entries_bitmap); + tc->tc_entries_bitmap = NULL; + } + return err; } EXPORT_SYMBOL(otx2_init_tc); -- 2.25.1