From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DD527EB64DA for ; Wed, 5 Jul 2023 19:29:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=5HB0zwoFYBWsVfGnRaM4alUv43QG7jy8lQEUE8ZCQmY=; b=Evn64COWiYIIMl 1rrAQMoJmzD2SKSXSh9rcar33mq66O32nxFnFKR00djVzAXKaOUoeFFucdMtJon+PGfZPJmslsP4F MNHgx2VgAvPJJp5G/jkx4AONoxvODn6DPkMmPD0zxJ4xIVl7WzrhOIZAng9o/aK4lbCyRpphISk8W /jSe10nY+gucMRZq9grKTysZuNckCqscFHicpDpu9nUY8tl1sXlND2fjpNyw1wxw7I763cEABMDpO u7QWzjdhsWFwDa/LFlwq/1/oD3qSWfKIifg5VQiejCBrGgOctu96jmdNxjEiQbdSCq7qIrxkSL1uw q/PW9YpI1KBP/DkEcV4w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qH8Bo-00Gtlm-2P; Wed, 05 Jul 2023 19:29:24 +0000 Received: from mail-qk1-x732.google.com ([2607:f8b0:4864:20::732]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qH8Bm-00Gtl9-2P for linux-arm-kernel@lists.infradead.org; Wed, 05 Jul 2023 19:29:23 +0000 Received: by mail-qk1-x732.google.com with SMTP id af79cd13be357-76728ae3162so601297485a.3 for ; 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=JFbhOfxDC2dGD6hF33qJv+b3ozA00/A9ArbDny1UFaV0hd19JqQrFy2VX7dWuh4tQd r94logQkMckD5iUharvh6WFzPgmqJxymw5HYox3NoVXodgfVuIQiiOhjllNG4gDTFk8m mLGo5IWT/oVMZOsrfXxpE5f3OlTCWUrksZG5F4R8GlPhkDiR5PnqYZN63tnjeOoA2sUf Lzh9FuOAST60sxbFbBZM/C3KvrYTR4c+Y/RQfUCJNHvE0JE4VbTRzK4EEYDRdcE4k8tH ftqH7d35Ut/kq6iXWeS/HoVLOzD1gsNs0idM4pEKYwqm9OaRM0R5y9JAK66VTthmgZI/ x2Hw== X-Gm-Message-State: ABy/qLb85eBxFKePBPpSqeSTeewHOGw/4Rw+NuZv9auAbbA8GhoHvbQK UHCm3Ekzsl/8FPMg4q9lqX8= X-Google-Smtp-Source: ACHHUZ5CLNg08C/ff8nQYOuus6yDfKhh2rv7ePHk14UbrG5WD2+By7Xt/bnqOYrBoj9b22+UEmDJaQ== 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-Disposition: inline In-Reply-To: <20230705143507.4120-1-machel@vivo.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230705_122922_807840_87D0C044 X-CRM114-Status: GOOD ( 20.49 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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? _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel