Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp29486134rwd; Wed, 5 Jul 2023 12:34:10 -0700 (PDT) X-Google-Smtp-Source: APBJJlEErLVyLz6TnlLPRGkuTweVTrBv8T12eVvmplOndzWpbMPPhn6s6+9NjgtgRmJT5r9Z0lLB X-Received: by 2002:a05:6358:cb2f:b0:134:e413:4d3 with SMTP id gr47-20020a056358cb2f00b00134e41304d3mr12339757rwb.16.1688585649936; Wed, 05 Jul 2023 12:34:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688585649; cv=none; d=google.com; s=arc-20160816; b=uTCqy8d3pB5uqV02wx4dIyVZPedVbRW0FYTlFW322HYjt0Ezy8J+nGDUp3+idYGjtT BfmCcc5FX2B+gbCKGP4HRBAKtk5dj6tVWKCQNVwd+bw/KuluRJzgYsyfWx18qeXulX0j FU6F7ySqsCnElnSF/mTw609SjyJI29jmMUbrp7yurmyhSRey8lOmHbcU7rWsk7clZTbL W+mZlV45yyuRJJBTbRpJh7dp3KxQcePqEISnkw/A84CI5dDhf9Bid8eVNPaLgGOq20cH jOrrt26HnQt9jtIeh/auoHNcynl6kBrnxafHbMLqVnT/p14CrnoQHQdbvWke9SFV6C2q wQPw== 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=m9i0JXZMtviSmKmtWbzYYg1fd/B+MoL8xjoG+LLog9A=; fh=SQKnQh+Yc0/hOpW6U1SpzU9CMAy0wPlYXXRtg240BG8=; b=KB08UkzRX/ka3Cz/bZxDYMYW3jIFblHfZxWtst8gzKnYxkfRc8/hYohUltEcpIQgm4 bA7cX0ITY6T71L0GpSnwfgERnNcoGatemoZ+9Bc67uHcmrFZp1NYAFZknNAUYnH1uIsv A8Jsd7hJdZA/gg/GGD2l8+FjUljSBCnUiO3xmiEmMjh6VlQ4H5GodZwkgXrLSgbCsvgE 4sFXIqVO2HA02eQVugAa90CbXA0rU//X89qZF1owviDvwZKwiUfNStPErIEAmo9bv8RD uDDBdzmgeCQ3RJLNY4eaP1QLydbqBy+v8quG6j6w6OGnMwFmsZXK2Uz2IWB5ZbjKPTlt bn0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qaRFN7is; 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 x184-20020a6386c1000000b0054fd504e80asi6658325pgd.542.2023.07.05.12.33.57; Wed, 05 Jul 2023 12:34:09 -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=@kernel.org header.s=k20201202 header.b=qaRFN7is; 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 S234006AbjGETRQ (ORCPT + 99 others); Wed, 5 Jul 2023 15:17:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233973AbjGETRF (ORCPT ); Wed, 5 Jul 2023 15:17:05 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5742448A for ; Wed, 5 Jul 2023 12:11:51 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9FB9A616F0 for ; Wed, 5 Jul 2023 19:10:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 830E6C433C9; Wed, 5 Jul 2023 19:10:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1688584233; bh=5v2Jcbu23jOZ3NaXiTSv75lRiQHToTnbx3t9Ier4ieA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=qaRFN7is3IkXgvJVuogihBRu2z0M9hIkMOoVNNKz0aqlLr9bWl0sGVxKe64O/gDmf COB5jjtZ75SrFflvrcpcpOz5laZmr+8IAq8TFsZauo8Qxt7Z+vTsiguElCzwp3lIgR HanYQpRRWpy8UzeRiJmTEDbxBR2xvZxbvl82AMN1bgrz9KDfpW5t86f8dunErGqzIv ANDRrSxrxoUuDv3zvDDByMd3ACbFRRg+zfm7ATTy2aiQPtH2IWh/sYZyeZ6zK2ryP2 plqsqzfA/8zk4qdInLZoucroxki4WylAJh6guGCNBePq5eLsEjuHt8YwdLm5ODeSGO v94qReik0nw+w== Date: Wed, 5 Jul 2023 22:10:28 +0300 From: Leon Romanovsky To: Wang Ming Cc: Sunil Goutham , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, opensource.kernel@vivo.com Subject: Re: [PATCH net v2] net:thunderx:Fix resource leaks in device_for_each_child_node() loops Message-ID: <20230705191028.GP6455@unreal> References: <20230705143507.4120-1-machel@vivo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230705143507.4120-1-machel@vivo.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Wed, Jul 05, 2023 at 10:34:56PM +0800, Wang Ming wrote: > The device_for_each_child_node() loop in > bgx_init_of_phy() function should have > wnode_handle_put() before break > which could avoid resource leaks. > This patch could fix this bug. It is very strange typographic. You have ~80 chars per-line, while your longest line is 40 chars only. > > Signed-off-by: Wang Ming > --- > drivers/net/ethernet/cavium/thunder/thunder_bgx.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c > index a317feb8decb..dad32d36a015 100644 > --- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c > +++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c > @@ -1478,8 +1478,10 @@ static int bgx_init_of_phy(struct bgx *bgx) > * cannot handle it, so exit the loop. > */ > node = to_of_node(fwn); > - if (!node) > + if (!node) { > + fwnode_handle_put(fwn); > break; > + } > > of_get_mac_address(node, bgx->lmac[lmac].mac); > > @@ -1503,6 +1505,7 @@ static int bgx_init_of_phy(struct bgx *bgx) > lmac++; > if (lmac == bgx->max_lmac) { > of_node_put(node); > + fwnode_handle_put(fwn); > break; > } > } > -- > 2.25.1 > >