Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp30142695rwd; Thu, 6 Jul 2023 01:16:09 -0700 (PDT) X-Google-Smtp-Source: APBJJlFETPmH7CUdyVGTjent6kjMS2Hd33ZjJItjH3I57J3Uqb0bTJ7kXJL4z2gr60/13n/wD+Pe X-Received: by 2002:a17:903:230b:b0:1b8:9461:6729 with SMTP id d11-20020a170903230b00b001b894616729mr1359537plh.2.1688631368854; Thu, 06 Jul 2023 01:16:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688631368; cv=none; d=google.com; s=arc-20160816; b=q2np69TiDHwMsR8/9O9CAhT/iplnzawudmuYjD1loQWanNW1K5BZeEShqimKoXh6rP hDjuXBbfI+aE4pFwoN/efK5eHJDxxldF/rY65ftfLyrb3a6SkSb9KLEGg9zhcaImzy7G Rosx6d1tEZpJZTY7sXlze0xs5DSiX5krXOY9d8kFSTh8rtENnr+EocVdZQf0lD8yxA4m oOWcvNX0tTYT7lg1uEHaqVh/eS07WPc5bHtaM8R97SBEJpuNslKNBr2l5S9kVDQfJAIc qol/UhQRI6LYD6sgOyjq/l88G8O1qqc1aNFzuAqvJhFC0CTiOeXCW2KfOXNNsnMbpTIf oVpQ== 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=i/plCmZ9/AmbcWhfhWn7T+U6mHjLIWIcG8SGRnetPKk=; fh=Jni5H2jC5aN/sTcxa/hQLi6cEF/lyRkGGM2BKmK2wB4=; b=c9znuEAxvpC/Eq32NgRg2koLfN+eVcA6CTNBwXE77jKVjAQ1RBecOq2PX0fZOqWNMn PmUR4nGY7x+iJMzfQbRmjQUHY79qxvDa/RD5pkT7uOdH6m5RufKtlZTirwoBLbxEJLxo bedMfSTtHRa1cw8ZNNfYAw/Qmp+0sKcbsiSFIKob3OasApMJ1KUY7cRRMDz2XnlhqXRN hX3stzax3WBVAWFGsB6hFrj3E5rzmwwcIREMV5r1MC2p/lBVbGT6PCbR8qKkYYU+fkAF +D0v/5UF7m2Ht33hmgYq7daxR+5HKT2hmhbkSQVs/eB0boZRei/Eb6b/arnQkp4XWBCd bV2w== 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 p12-20020a170902b08c00b001b8b49b13e4si755130plr.554.2023.07.06.01.15.53; Thu, 06 Jul 2023 01:16:08 -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 S233602AbjGFHnZ convert rfc822-to-8bit (ORCPT + 99 others); Thu, 6 Jul 2023 03:43:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233637AbjGFHnX (ORCPT ); Thu, 6 Jul 2023 03:43:23 -0400 Received: from mail-yw1-f181.google.com (mail-yw1-f181.google.com [209.85.128.181]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 589121BE8 for ; Thu, 6 Jul 2023 00:43:16 -0700 (PDT) Received: by mail-yw1-f181.google.com with SMTP id 00721157ae682-579de633419so5351957b3.3 for ; Thu, 06 Jul 2023 00:43:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688629395; x=1691221395; 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=YU7wIuB8pzU5mgZRjLNHZb0xDTBNcfDXYxTP1tuxTqw=; b=WdrBz+PZBZIf02MvjOo+OpJOa9pT97eQc5IQ9y1j4ruDxfrBeUo6tTdM6NUn+yJ88s z12WfgLUQwgrW70DhX41gTERqmCwkkKzTPy9Osjd0pPJQmIQLK8thTkhEdAgHaGkHD9Y 5b7vBrGw3e3xdFVwUJS1kCmO1/impmGlJJ7FHPdQ3AGj4p0byA0NvQZlJ7LF9yzUosZp WpFWdO3TDpI7EQcrsZDqigyvVvbGrAYg0BdJjx5HtOHnmnX0g2njyqbeNeVH57pfZ8Ov EqhbdqTphv3fM4BG3c4syMLcgpD4kLPZQHTgrnn9tuA2Fjkwg5OFvLZKvDBpWAY2FytB Wkng== X-Gm-Message-State: ABy/qLblfQ+BgPQhRNGQaFYfd9Pg6WQTYBOe/7lTOUtOsFJUMXbvb8uK NMTVtzP+mryaV0nHz+1Br5aMzVL+0R5Zbw== X-Received: by 2002:a0d:d345:0:b0:579:5bbe:b022 with SMTP id v66-20020a0dd345000000b005795bbeb022mr1145588ywd.30.1688629395309; Thu, 06 Jul 2023 00:43:15 -0700 (PDT) Received: from mail-yw1-f175.google.com (mail-yw1-f175.google.com. [209.85.128.175]) by smtp.gmail.com with ESMTPSA id v76-20020a81484f000000b0054fba955474sm193506ywa.17.2023.07.06.00.43.14 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 06 Jul 2023 00:43:14 -0700 (PDT) Received: by mail-yw1-f175.google.com with SMTP id 00721157ae682-57a4a476bbfso4525437b3.2 for ; Thu, 06 Jul 2023 00:43:14 -0700 (PDT) X-Received: by 2002:a25:d0b:0:b0:c62:9810:db27 with SMTP id 11-20020a250d0b000000b00c629810db27mr1001959ybn.60.1688629394538; Thu, 06 Jul 2023 00:43:14 -0700 (PDT) MIME-Version: 1.0 References: <20230706071310.38388-1-luhongfei@vivo.com> In-Reply-To: <20230706071310.38388-1-luhongfei@vivo.com> From: Geert Uytterhoeven Date: Thu, 6 Jul 2023 09:43:02 +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 , Ivan Bornyakov , 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_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 Hi Lu, Thanks for your patch! 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. 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