Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1950038rwb; Fri, 2 Dec 2022 03:31:05 -0800 (PST) X-Google-Smtp-Source: AA0mqf6aEE1js5mReHmB4FUJGaQKlOXCY6xL7Xf0dQbMvK60vKaPa4Ic1Pa6jF2SbRc5DRappma3 X-Received: by 2002:a17:907:3e11:b0:7c0:7b2b:db17 with SMTP id hp17-20020a1709073e1100b007c07b2bdb17mr18366021ejc.312.1669980665626; Fri, 02 Dec 2022 03:31:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669980665; cv=none; d=google.com; s=arc-20160816; b=orRbze4gF+AYXaeszeFpTHWwfMlApzojnF2XVtwmeR0ixfVTq2Cdm9mf7AQn04EtmJ b1NpVeHIVM4FtYD+qmFO9nbodbfwTWxyaS/TU0RIswWLxOfe7OHZsC5bBhH1J3uNcD29 znT/r+AV/T3ddMVs8pG8fmlsEKS3JbkOl0vfNRYuOPJVZaq0bhRW2Np+g/42YHB8pE6q c4Rw6KyVEqbPemeDIxiJB9VeXVYOcHUrlBbGOTC4iyndMYjNqOqw1HiH8g08+uki34sp dSMV0D7vRoRMsyx2eRy72GQ8byAqHCSMW6EC2NDRYsgq/K1ixA+GHIhryYrg0XWUAxuz 9qUw== 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 :message-id:date:subject:cc:to:from; bh=CZzupZYYCOHaBcsP51NF7E3lNz9arUaP/eq62M1rcRU=; b=t/eXPTD0OAz+FXdys7+KzuVWzyU3G5lhLgaHyhpSj01qCeQXpoo3fsCXrP5FC6haoX V76I2xpxispyJfHIuD/LwF2ouBrUqk87hEWciRs9FH4NCIlDMJYt5+QlpWHNDhJACnVQ EIFIWxjWFj/J8oFwDsEOJz8pL18c+i7ddOh6O2EaQmrQXppvhg6z0chgqBP+8SoJEiBl XEslMrULvOXVeUQPZcOgavR9zkkJvx++K1fQygVGrjEB+iKP49Mrw6Pjvv9txN/jLRaf uRr7g/TEQpeKsk7zBzk2TaVe5QB1lFcTiUye026WGmY6zD42Hlq/qXarBmrR6n//ND6U GI4g== 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 n2-20020a170906378200b0078d8cc2006csi5242547ejc.697.2022.12.02.03.30.44; Fri, 02 Dec 2022 03:31:05 -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 S232745AbiLBLEm (ORCPT + 84 others); Fri, 2 Dec 2022 06:04:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232740AbiLBLEh (ORCPT ); Fri, 2 Dec 2022 06:04:37 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5600BC5AD; Fri, 2 Dec 2022 03:04:35 -0800 (PST) Received: from canpemm500006.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4NNqnL3QTyzRpvK; Fri, 2 Dec 2022 19:03:50 +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, 2 Dec 2022 19:04:33 +0800 From: Ziyang Xuan To: , , , , , , , , CC: Subject: [PATCH net v2] octeontx2-pf: Fix potential memory leak in otx2_init_tc() Date: Fri, 2 Dec 2022 19:04:30 +0800 Message-ID: <20221202110430.1472991-1-william.xuanziyang@huawei.com> X-Mailer: git-send-email 2.25.1 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 --- v2: - Remove patch 2 which is not a problem, see the following link: https://www.spinics.net/lists/netdev/msg864159.html --- 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