Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp30131105rwd; Thu, 6 Jul 2023 01:04:34 -0700 (PDT) X-Google-Smtp-Source: APBJJlFHzox/whVRCcya6VH56+J8knfL+DbFL7aJdbSwwB0dDJS6vGyk/3HvoPS5ybDHD+gGG69Y X-Received: by 2002:a92:1a4f:0:b0:345:b6e8:6d54 with SMTP id z15-20020a921a4f000000b00345b6e86d54mr1375836ill.31.1688630674350; Thu, 06 Jul 2023 01:04:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688630674; cv=none; d=google.com; s=arc-20160816; b=r32W3Hw0MXwaPjwmO5/wVaU02VOYpwHbXYyCeErKpHAxdhbLMCBU5LcAiX5lXuK9f6 RgRigsWy86Bl+/Iyw+DYImkhNrQIyRTShAaLEtXl9QjnxvFAQdSmjZlyUMgjTq8ZM9+I GprFxP+9cTPnb7bnJg3B5IJ+3RgL2+ib9FqgYx63LUU0pRzmyb3JVno12t3jzPqX5eHv F6POfcNPv5zZAg8DzA9FxPXcnBwrPvyNYPIw3R3LENzG8DHzierrXEUtk+Wo9v/yDdGF RnEaXgruE9XT/8IKxV60r51pK2QIYcUj1rbgS7p8eninQ4MeI66lPPUj3LjZr80D3p0l gDHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=eR2ChH0fB6LiiAnT2YuC9gr8JG896ZWAnTPGRofh8/Q=; fh=ZLGVAiLXjBZAMK3taXy6J/TSkVwJcCf1FTdjWTzmKNE=; b=kNyC3yBhh1msXATUJa1NOlgxPuzefIc4uNM7IQQTQFUykGGCt6T0YG9ujgWk0BqqIW ol1iV6PPMm3fAiF8u0U2q7rQ0IkrPI9KbPK5r/xpLF3/CbPk9dNq+WAJfs1M2lqweqaN MUyex5vQ8p+mcQWHlo/V193gEESBtdESBx9/5lObT7b9+j4KOevgqFVpapq+qawG6HbQ R6QvtYAi+B5USme81pZpZ7Lq7bZyVxqLbfiJVahrgcd6rjAvYqBwUlue0HtrGLWE84I8 tscVKPj4NLkHrc0+fYo5HR/ETbOeU6VopDDqFzfVKTWMfAS8g53NIDYJFQtajKdOt9RO Ou9Q== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a62-20020a639041000000b0053f3d04e66csi926176pge.699.2023.07.06.01.04.19; Thu, 06 Jul 2023 01:04:34 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233344AbjGFHxV convert rfc822-to-8bit (ORCPT + 99 others); Thu, 6 Jul 2023 03:53:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229508AbjGFHxU (ORCPT ); Thu, 6 Jul 2023 03:53:20 -0400 Received: from mail-yb1-f177.google.com (mail-yb1-f177.google.com [209.85.219.177]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 243C5121 for ; Thu, 6 Jul 2023 00:53:20 -0700 (PDT) Received: by mail-yb1-f177.google.com with SMTP id 3f1490d57ef6-bb3a77abd7bso395264276.0 for ; Thu, 06 Jul 2023 00:53:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688629999; x=1691221999; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oLFxQ4JHG9tvjlmQac1kJ2yw4Iq48iBlz2d7dmbQkwM=; b=Xmv8nu2NisZ1/cDKLFN9JzF+WIMGDSnW5CijkRATou4msOFbKP++x2uEGn0dEIfKuY uizBcoKrtaU7y8mCko9EqzQTSYYoFlBGp5qDbMc3SZV1qVI0JECpOkeaYZKAWif0G6EL jeJcocnU4um8TjF5y1bowI8oQ5uiHof2bRgUURv1bs6v5yN8zCavrzVmIf14EVvUVEuv CyqVwcKXUoOKJgGj34jYD+EASMEbSL6e75YerS1OB8apSB8lYyzvcINv90HLuXh04CI0 e3t2OLUWEwcaIf2xNjytUZ+YfKYpqlkgu8jY4vJtRdr4k8gpwVezvGpitQyaiFHWPp+y sCjw== X-Gm-Message-State: ABy/qLYQz/avAoQvsGIv2SQcSq/GlUqTOMN5nWVR4DI5vfw3m1E1YOpN LCJrEUXskQZbyH1OsWe9vACJj4Eto9HBZw== X-Received: by 2002:a25:becd:0:b0:c64:5116:795 with SMTP id k13-20020a25becd000000b00c6451160795mr1065525ybm.65.1688629999206; Thu, 06 Jul 2023 00:53:19 -0700 (PDT) Received: from mail-yb1-f176.google.com (mail-yb1-f176.google.com. [209.85.219.176]) by smtp.gmail.com with ESMTPSA id u9-20020a25f809000000b00c64ff4e745bsm188001ybd.51.2023.07.06.00.53.17 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 06 Jul 2023 00:53:19 -0700 (PDT) Received: by mail-yb1-f176.google.com with SMTP id 3f1490d57ef6-bfe6ea01ff5so381043276.3 for ; Thu, 06 Jul 2023 00:53:17 -0700 (PDT) X-Received: by 2002:a25:7804:0:b0:bd6:8725:2258 with SMTP id t4-20020a257804000000b00bd687252258mr1002406ybc.60.1688629997542; Thu, 06 Jul 2023 00:53:17 -0700 (PDT) MIME-Version: 1.0 References: <20230706071310.38388-1-luhongfei@vivo.com> In-Reply-To: From: Geert Uytterhoeven Date: Thu, 6 Jul 2023 09:53:05 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] drivers: bus: Fix resource leaks in for_each_available_child_of_node loop To: Lu Hongfei Cc: Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Rob Herring , Mark Brown , Saravana Kannan , Geert Uytterhoeven , Minghao Chi , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, opensource.kernel@vivo.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no 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 Thu, Jul 6, 2023 at 9:43 AM Geert Uytterhoeven wrote: > On Thu, Jul 6, 2023 at 9:13 AM Lu Hongfei wrote: > > Ensure child node references are decremented properly in > > the error path. > > Which error path? > > > > > Signed-off-by: Lu Hongfei > > --- > > drivers/bus/imx-weim.c | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/drivers/bus/imx-weim.c b/drivers/bus/imx-weim.c > > index 52a5d0447390..d05472f7c20f 100644 > > --- a/drivers/bus/imx-weim.c > > +++ b/drivers/bus/imx-weim.c > > @@ -251,6 +251,7 @@ static int weim_parse_dt(struct platform_device *pdev) > > else > > have_child = 1; > > } > > + of_node_put(child); > > This is not an error path. > > for_each_available_child_of_node() walks a list, getting a reference > to each child, and releasing the reference afterwards. FTR, calling of_node_put() manually is only needed when breaking out of for_each_available_child_of_node(). > > Have you tested this patch? > I expect the of_node_put() to trigger a refcount underflow error > message on the console. > > > > > if (have_child) > > ret = of_platform_default_populate(pdev->dev.of_node, Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds