Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp7846901rwp; Wed, 19 Jul 2023 00:51:53 -0700 (PDT) X-Google-Smtp-Source: APBJJlE1j6YfRW7RUPx1jPU0kSoCjmI0V6lq2HYJk2hlH+825aJ1II1BL0yCRhXQayJMp4BG6Rzd X-Received: by 2002:a17:902:d4c5:b0:1b8:e41:f43f with SMTP id o5-20020a170902d4c500b001b80e41f43fmr2165818plg.27.1689753112782; Wed, 19 Jul 2023 00:51:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689753112; cv=none; d=google.com; s=arc-20160816; b=0/Ap8Tj+fvEsxHH/NDC1InHh6U2ob4xMpFt4BBIcfDLq3f1EK4fcSJfFp3u640cCR8 ktUdHPIjT+TsVR86gRyAmjCXep45nQI4v7LecAfIQ9bNkuHJjDMiAYc2oOxE3F6F/Xla W3d39GcbiuoUun78RVvmBUQc0V8s5tfdpHZqAGAsAJL87jUXA9w9IKvCluhGQ/Iu0aYc iTuoiXYFYYbQTe90wklGtoUyAXpqhh7j+JVNEUMc5MbF48UTYBmX5O1WDJYF4lqVKZg0 IIoZ6K5+qHgCR6qp49py1Ya10byIvRq1yT6KtA4JN7XzDD9aRGrfVG1oBzpUyiqMm62a XAzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=c00oKqBto6DPWd2lo8s2HrcOnHxuVN8dGhbqZfUYyrU=; fh=L4qwUHLcFLMvjB6a3VR/pklDPrptQiuhSAeJ+RSdg7k=; b=bRXANM2fKFZJ5XqHE+tn719mbQtnUchWiEBAJp3LamPliiDdjrwIXi4n1Gixmd301w 8GjcfQGpZU2S2cxaBU1nHV/fOvbMFZrz1jf+2hM21aQ/7z5gE3cBAn7EyFhOpAdn5du5 gKAyH2sD7k57S+xXA6dLToovDLe27t2R12ambNQG50QXweU5TWXcTn7hV4qkmh61DKeN RRtlWdD8ZGhiJSya4MhGAyYQWiGy4ctyGihtA7lA0LNNQQWHWUD5s9t/78B7vIiCdcRD p1C4HHq00c7xLMgMcJ3ms1opyFGvgdCcIkO63okp9RbzXkO64/BGAtpFqTXMbPVf+N9y 2CNg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xs4all.nl Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p18-20020a170902ebd200b001b3f9cedbb7si3068121plg.398.2023.07.19.00.51.40; Wed, 19 Jul 2023 00:51:52 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xs4all.nl Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230358AbjGSHng (ORCPT + 99 others); Wed, 19 Jul 2023 03:43:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229712AbjGSHm7 (ORCPT ); Wed, 19 Jul 2023 03:42:59 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D11461FE8; Wed, 19 Jul 2023 00:41:57 -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 642F160F19; Wed, 19 Jul 2023 07:41:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 70B9EC433C7; Wed, 19 Jul 2023 07:41:54 +0000 (UTC) Message-ID: <1dfd0643-bec6-5360-bbd1-968848b760f9@xs4all.nl> Date: Wed, 19 Jul 2023 09:41:52 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [PATCH] media: Fix resource leaks in for_each_child_of_node() loops Content-Language: en-US To: Lu Hongfei , Mauro Carvalho Chehab , Matthias Brugger , AngeloGioacchino Del Regno , Moudy Ho , Ping-Hsun Wu , Arnd Bergmann , Sun Ke , "open list:MEDIA INPUT INFRASTRUCTURE (V4L/DVB)" , "open list:ARM/Mediatek SoC support" , "moderated list:ARM/Mediatek SoC support" , "moderated list:ARM/Mediatek SoC support" Cc: opensource.kernel@vivo.com References: <20230530094541.23396-1-luhongfei@vivo.com> From: Hans Verkuil In-Reply-To: <20230530094541.23396-1-luhongfei@vivo.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,NICE_REPLY_A,RCVD_IN_DNSWL_HI, 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 Hi Lu Hongfei, Please add the driver name to the subject line: 'media: mdp3:'! On 30/05/2023 11:45, Lu Hongfei wrote: > for_each_child_of_node should have of_node_put() avoid resource leaks. > > Signed-off-by: Lu Hongfei > --- > drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c | 3 +++ > 1 file changed, 3 insertions(+) > mode change 100644 => 100755 drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c > > diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c > index 19a4a085f73a..5a6a61d68cba > --- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c > +++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c > @@ -1128,6 +1128,7 @@ int mdp_comp_config(struct mdp_dev *mdp) > comp = mdp_comp_create(mdp, node, id); > if (IS_ERR(comp)) { > ret = PTR_ERR(comp); > + of_node_put(node); This is needed, > goto err_init_comps; > } > > @@ -1137,6 +1138,8 @@ int mdp_comp_config(struct mdp_dev *mdp) > pm_runtime_enable(comp->comp_dev); > } > > + of_node_put(node); > + but not this one. The for_each_child_of_node loop ended, so node == NULL and there is nothing to put. Regards, Hans > ret = mdp_comp_sub_create(mdp); > if (ret) > goto err_init_comps;