Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp29491905rwd; Wed, 5 Jul 2023 12:40:13 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6cWHaSZfV5IHJEYYGiRyL4NooKdm9lMOa2Q34hsKWs6q0XbuHtdCB3cj/0dzjK2I/0N7gs X-Received: by 2002:a9d:6b19:0:b0:6b5:ee8f:73af with SMTP id g25-20020a9d6b19000000b006b5ee8f73afmr19260544otp.5.1688586012718; Wed, 05 Jul 2023 12:40:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688586012; cv=none; d=google.com; s=arc-20160816; b=xAiRFu/FIBFPV2/vOJbggf6uQHzOYqKOPGetoqAb/PeJDVzH3f2JtVaXkoBt01QEqY 0YKE2sPd/wR0ELHCptDrP9F4lgU+qYIghb9RlzlafGMKQfBMXUlb+IYkEITF4bV2A2Oh xf/z4Sd2h+JVbJMr+SUZ8XnhaNDr67+xiERx/SZR1EemJy0CSHqIf28mQDTGDq8GSmkl 9++rTvIqJ6fj59dq0FhqvA23jgKDmZVwzbZ7d1bRTbuVI7fOLYGbMZLfHtQb67zbR9Jz SFiwKccDrvIirsMFm5OdzOZ2heoglnd9W5a1emtf/yZizNVMGpIfWlQygrWLRDJjYADZ fL7g== 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=aX9x7UocICoyKf+7dpuLhA5gusj7thE6eymrovOEi1Y=; fh=SQKnQh+Yc0/hOpW6U1SpzU9CMAy0wPlYXXRtg240BG8=; b=TcJOVtQQ9hIYCIUFYZjmFKFsgCMAXC+RU+R5iG+7e/jZWTirHzRxSdKe/M7wSmy85o +ga4aYUufxWFuGuaqc+w19NKqfa5xTH36AaplBv1bs++prg90rcFn53XB8fZYS8y+yfS VofgCto3k8cg9+7yamuhRIIFMVIo/40SdNVzXnSfSMmbbfGF8M89Z9x3DegaL+dJA+hn yUUMWUPF36fvKKjVncsdGE9nhMicHtllIg7x+erKwIQggXeW1qnzK2c5glqc2ksTjMQY 7t2J+dIeR6lT49RVwMUVfiebma8JTza8XmIMTV4ViV+9TQbumKkkQmp17MKHt3Alu35X t9iA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=OS4puIf3; 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=QUARANTINE dis=NONE) header.from=gmail.com 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.40.00; Wed, 05 Jul 2023 12:40:12 -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=@gmail.com header.s=20221208 header.b=OS4puIf3; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233660AbjGET3Y (ORCPT + 99 others); Wed, 5 Jul 2023 15:29:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232185AbjGET3X (ORCPT ); Wed, 5 Jul 2023 15:29:23 -0400 Received: from mail-qk1-x72b.google.com (mail-qk1-x72b.google.com [IPv6:2607:f8b0:4864:20::72b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28B9A10F2; Wed, 5 Jul 2023 12:29:21 -0700 (PDT) Received: by mail-qk1-x72b.google.com with SMTP id af79cd13be357-7656652da3cso602639185a.1; Wed, 05 Jul 2023 12:29:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688585360; x=1691177360; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=aX9x7UocICoyKf+7dpuLhA5gusj7thE6eymrovOEi1Y=; b=OS4puIf3aHwVkCom7A3NU/1M+2pAzfOAwkAJqE44r80PeCkfJxdtGXY2zufhkQSBFi Wy0a9gsCbgIKr2OAA1VDZQPAHtbdkRFMqK7nrM/6PKcu7U/Z7lSi+eg0TR/tgdZLmaU+ kN/TddZcO3tHKL6tAA5DZi/yW3p60ImHJWV84St9EYJPzeIe5zoF6QsCs1ghcjdDiP4H MMlSynDbfCJFSkxpWHzibsQYud9RqV0j40J0PaSqMQOQzqVEvNVBXXa1BMZHvhD6nBrf uT83kN0b9wf/2vdE2cTGk/b+k3J43cW6FE+XXn+nlLq1N8rwe6x2mGOxQJpLLhGd6er/ s1Kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688585360; x=1691177360; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=aX9x7UocICoyKf+7dpuLhA5gusj7thE6eymrovOEi1Y=; b=dP2btGJHVqI1fH3MgXmMASVC89bUNWRDHzib6p/Va+6z4VfAlsgLY7HeS6aMNbw8w8 yV9xcZJknkM/zE/jQXTdO9nIqliDXEd/tBt6vkwi91R4xtVHagL6bCO0GM3Ub5sDXwtv t9nCu6RMCVVAxsLp2gmti6c2780H3etoYmDQMBC/SN8PiBj+gvzUhoCUlJW4g0dTNxRW vfi1yfnvRHPlAz8ZymBBwnB/nzhh8/wr9sAiFN/oAYx0rgTUcj14W/W2To4ng8meTyXC +7y1I9SRmeNjZQYV7h+sM7r9U5pPJ5KSJlu4ce/fbilpr+kPW/+bN2F7MVtuLwOCsVli S5gQ== X-Gm-Message-State: ABy/qLZOTi72s9qePQMgMb9vI7Ytd6whCXohHBgtwKwulRMWLf0gp8p7 iBtOUBpyCnxsgFiidr3YhTU= X-Received: by 2002:a05:620a:17a0:b0:767:1d7e:ec40 with SMTP id ay32-20020a05620a17a000b007671d7eec40mr19716096qkb.1.1688585360166; Wed, 05 Jul 2023 12:29:20 -0700 (PDT) Received: from localhost (modemcable065.128-200-24.mc.videotron.ca. [24.200.128.65]) by smtp.gmail.com with ESMTPSA id m18-20020ae9e012000000b0075d49ce31c3sm11206136qkk.91.2023.07.05.12.29.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jul 2023 12:29:19 -0700 (PDT) Date: Wed, 5 Jul 2023 15:29:19 -0400 From: Benjamin Poirier 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: 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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 2023-07-05 22:34 +0800, Wang Ming wrote: > The device_for_each_child_node() loop in > bgx_init_of_phy() function should have > wnode_handle_put() before break ^ fwnode_handle_put() > which could avoid resource leaks. > This patch could fix this bug. > > 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; > + } Fixes: eee326fd8334 ("net: thunderx: bgx: Use standard firmware node infrastructure.") ? > > 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); \ fwnode_handle_put \ of_fwnode_put of_node_put(to_of_node(fwnode)); With your patch, there are now two references released on 'node' (two of_node_put(node) calls). One reference is from device_for_each_child_node(), where was the other reference taken?