Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp4620901rwb; Sun, 4 Dec 2022 05:27:12 -0800 (PST) X-Google-Smtp-Source: AA0mqf533qUe+bvmX400zbnIWx0TwD7tJCYisFsPctu+Yw58r+ReKdwZkYVrp/W8MSWRMayUip/B X-Received: by 2002:a17:906:3293:b0:7bd:f540:9be7 with SMTP id 19-20020a170906329300b007bdf5409be7mr31391071ejw.434.1670160432052; Sun, 04 Dec 2022 05:27:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670160432; cv=none; d=google.com; s=arc-20160816; b=KpLNtOxaNMxoFuW6aHUKUhUEKQzUwg94QYQ58zp83PUIFXTl+kCzUIWvEOLilJfA+A E5eQmdv6dDSCiPhwD54hXJdhaW1Ti5C+7xsFB+H+DO8qQmEh2d3uzm5ZKjEJpBKkgvn8 MnaY7wal79zNJihbqyfibVVB7dvhtyMaEGG3ZXLK293YDqIVQlC0U0CJWyUrZYBhC4RJ GbLm3nPuX7TXomHrw1YFC00c/CFn6YRCs3hNyLtizcPttQm2o3Bw+h9rsv6Wd7MAwyEw FaGt/BWcmZAoC2E7dVhgbBmqsVarR0kQ4GIx+YFPOqMZw7uGvIFxXCyNV/06RC4aJ36m fc+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=BU7u7LZbvEG3nGAT2+uiTtPdrrt3icerlERP7U2WcSY=; b=cKjm8v0wNbhgFwRzMttLekDFHMc/kmb+GR0C2PK6DEEvhrbS13bt/2La82upbkwau5 Z+D6r5FCwLxa9NB/CckoE4WwgN/qftd98PShipj9JmX664QVFn055607MIwq61lZ8CNB cTTEcRpmf++h9kBu3GWYvVSbyNNCDmHkZRQq6EBbcyEfYdvqjQcps8ELdvm/kNTP+4tH /3nB4ONZ5j+sR7cdDfkSQOprEOho7Fj0ot61Mnle8SO0w1bFNHu8EahtKtYUHleZUOnu tOH7FJh8NhJyLTBS31gOtTkpyU7RKO3SV/sugJJPLNOJoDXE6TuZ5wNXLvgh33gIhukW 9ShQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oe73S5Cn; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ft31-20020a170907801f00b007b5dd3e6995si7117042ejc.917.2022.12.04.05.26.51; Sun, 04 Dec 2022 05:27:12 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oe73S5Cn; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229949AbiLDM4A (ORCPT + 82 others); Sun, 4 Dec 2022 07:56:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229539AbiLDMz6 (ORCPT ); Sun, 4 Dec 2022 07:55:58 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F9DE1648E; Sun, 4 Dec 2022 04:55:57 -0800 (PST) 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 17D04B80918; Sun, 4 Dec 2022 12:55:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9C2D2C433C1; Sun, 4 Dec 2022 12:55:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670158554; bh=8yRgtw2sqbmn0sbuN2uygsx/CmEH3xWVwet848rkPeM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=oe73S5CnLcYVnjryVw5zKzNeITWOUd6MAR9WezfDI7EZNvRnTwQsM1muhe7F4yp11 sUE/OoTwBZ+id9Y9+bInvHLCGeGytmEZ3AvtbtddbK44gAO9XG5bdWNLsLckg9bCtu Dgtg9NAKqB+5ldcvzbnJmcYhSyy5tJWxqM2UbQR822fFEqkLAlIYfQ8lLcFDUYT1Yj LAHx5MXsrzDpbMLhSQ57R8wCf2vlLcjqKTPcrCniEGimkc1W4SD/qaI5o+2F5XTdZe 9py2XIebbQHY4sgwm9R6PYfbJ3QL2CO7CKvO88/2GWNOnkNr3V1f0D9HSMvhY7hIS6 lT9O4Yxkz38UA== Date: Sun, 4 Dec 2022 14:55:42 +0200 From: Leon Romanovsky To: Ziyang Xuan Cc: sgoutham@marvell.com, gakula@marvell.com, sbhatta@marvell.com, hkelam@marvell.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net v2] octeontx2-pf: Fix potential memory leak in otx2_init_tc() Message-ID: References: <20221202110430.1472991-1-william.xuanziyang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221202110430.1472991-1-william.xuanziyang@huawei.com> X-Spam-Status: No, score=-7.1 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 On Fri, Dec 02, 2022 at 07:04:30PM +0800, Ziyang Xuan wrote: > 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; Why do you set NULL here? All callers of otx2_init_tc() unwind error properly. > + } > + return err; > } > EXPORT_SYMBOL(otx2_init_tc); > > -- > 2.25.1 >