From patchwork Mon Jun 14 19:22:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 12319643 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F01C6C2B9F4 for ; Mon, 14 Jun 2021 19:24:32 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id B8664611BE for ; Mon, 14 Jun 2021 19:24:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B8664611BE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=canonical.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=IpmAlPPunVJZEhgil8adF7DZpVdmNjo2aJqWHBTvkD0=; b=o9y0PgFT0Kx8ue 7bg4jwg37db3G2bP7JSrdUBtHSzu3zadGQ94/Tw12NmGJgIY4fL3Q1L2XLJoSKtycZs+Qh4GDxjS5 T1KlfZmjk1ctoRNwZxRrDU0U1dviqcKqN+S8Jwi2L5uMaQQP2yNBzTB6oAI8/EvpmBc3tEMrRHIRC vZex4t9ty3u0tsV4S4AyR9Ki/lXPROrcbFlspL5mM7ok6PH/t9/AFkq1OcJ/l6fIS/zxo0gWOSMwY mVCx67upsX458f3+JMzPQbwjDlEknPfBW9KglTyGpcyZrR9DMaUZ1uGV+0NEjI9tDz+B6995ZpoYa dCERhnYQnMY7KFMnhM4g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lssAQ-00FqqV-W2; Mon, 14 Jun 2021 19:22:39 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lssAN-00FqpS-7D for linux-arm-kernel@lists.infradead.org; Mon, 14 Jun 2021 19:22:36 +0000 Received: from mail-ed1-f71.google.com ([209.85.208.71]) by youngberry.canonical.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1lssAL-0007tl-LC for linux-arm-kernel@lists.infradead.org; Mon, 14 Jun 2021 19:22:33 +0000 Received: by mail-ed1-f71.google.com with SMTP id df3-20020a05640230a3b029039179c0f290so19106867edb.13 for ; Mon, 14 Jun 2021 12:22:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=rFGGgn0LeG2Atp7rG87b+h6mzwgKd/t0DiWuNT+ZsKs=; b=CXKqbU382CWnd+cb14AKXWBlrp4ZBANy0jnXapWdEECjk8Mxf5ZuDCZblsUyz+Yn79 InZ6cKvNs5pUQWKRSdi9TGXw/9ptCy0/p+RO5VL+tuFbVavA+PN9pVwTwKjS7Blbo6Vn KBHNSWt5j26IJ8HovG7ya6cJ6WgZ/U3g7TKKRemshaXm40nfRZNgQk+ru7G1tP42AG1K qf7xOrLvOQXpJBJgwpFWDRtFkwJgqWcHF7a+6xXYBNb1diKHsbLKMHa/+tWZlJ1l3vqT w/Dbbkz4HDw5C2D/YWGX6Z8nVGAPnSAI78+wem7VjyGzHRIH9ng6+5HSsovCklgPec01 iT5w== X-Gm-Message-State: AOAM530zVytxnA/Ygb22+H9Q4Qxm7aKMYU6tIrORhIw/kfpyMVL8xODt blZAYXMFTfH8FKYbzo2XWtTPZ+TcydOUE11RIOm7qFsshZpNKbaVo9cUx8/Rtix0aj/hWYaTzvL +9A6h9aneAvgm68138ZpJYCq7eFP03c3nl3QnlWF0l5GOsFIFtw5G X-Received: by 2002:a05:6402:1d0c:: with SMTP id dg12mr18717266edb.155.1623698553423; Mon, 14 Jun 2021 12:22:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzMsv3DkP07aHqMhlbxy+wuR9SIRdpNR3T1Bs7YyzWUWFtxizGr+EqxJyt9kJ0TE/aqW6tjsg== X-Received: by 2002:a05:6402:1d0c:: with SMTP id dg12mr18717250edb.155.1623698553308; Mon, 14 Jun 2021 12:22:33 -0700 (PDT) Received: from localhost.localdomain (xdsl-188-155-177-222.adslplus.ch. [188.155.177.222]) by smtp.gmail.com with ESMTPSA id n23sm9071365edr.46.2021.06.14.12.22.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jun 2021 12:22:32 -0700 (PDT) From: Krzysztof Kozlowski To: Zhang Rui , Daniel Lezcano , Amit Kucheria , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Orson Zhai , Baolin Wang , Chunyan Zhang , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Krzysztof Kozlowski , Jacky Bai Subject: [PATCH v2 1/2] thermal: imx_sc: add missing of_node_put for loop iteration Date: Mon, 14 Jun 2021 21:22:29 +0200 Message-Id: <20210614192230.19248-1-krzysztof.kozlowski@canonical.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210614_122235_294746_849AEB60 X-CRM114-Status: GOOD ( 11.29 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Early exits from for_each_available_child_of_node() should decrement the node reference counter. Reported by Coccinelle: drivers/thermal/imx_sc_thermal.c:93:1-33: WARNING: Function "for_each_available_child_of_node" should have of_node_put() before return around line 97. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Jacky Bai --- Changes since v1: 1. None. --- drivers/thermal/imx_sc_thermal.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/thermal/imx_sc_thermal.c b/drivers/thermal/imx_sc_thermal.c index b01d28eca7ee..8d76dbfde6a9 100644 --- a/drivers/thermal/imx_sc_thermal.c +++ b/drivers/thermal/imx_sc_thermal.c @@ -93,6 +93,7 @@ static int imx_sc_thermal_probe(struct platform_device *pdev) for_each_available_child_of_node(np, child) { sensor = devm_kzalloc(&pdev->dev, sizeof(*sensor), GFP_KERNEL); if (!sensor) { + of_node_put(child); of_node_put(sensor_np); return -ENOMEM; } @@ -104,6 +105,7 @@ static int imx_sc_thermal_probe(struct platform_device *pdev) dev_err(&pdev->dev, "failed to get valid sensor resource id: %d\n", ret); + of_node_put(child); break; } @@ -114,6 +116,7 @@ static int imx_sc_thermal_probe(struct platform_device *pdev) if (IS_ERR(sensor->tzd)) { dev_err(&pdev->dev, "failed to register thermal zone\n"); ret = PTR_ERR(sensor->tzd); + of_node_put(child); break; } From patchwork Mon Jun 14 19:22:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 12319645 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 509BDC2B9F4 for ; Mon, 14 Jun 2021 19:24:36 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 16B1D61042 for ; Mon, 14 Jun 2021 19:24:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 16B1D61042 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=canonical.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=xaWjwJsXFv82X/4WZaV5fzGqoJpQ8O18tXNu0sd2MMk=; b=1AWY50grJJ9CDU /kdJyH8388wMjcMdzlZDf1AuvzfJYhk4H/6qD44Sw0v99FJq1sZGbiQvEck1lqZe1fPM1LxZbauHz llLF1eR28SwxskMcHcF+p/97MBqcav6iDzQzeaMWYr4FUAmJ1bM0ComXClRdMppBycDXITbq1SwG/ reaW9i4rF1Ky4Zi6KyOF0GDQeNoVCsmggtwbPnB3wi2whORlGuJ9lf13bH++XYmgEuel8g8DyTJhl 2gVSlJi8mu1naXbeMs0TBjobzcBy+Q2Ypmp8k38hIvjUHekK3UGtQVtALsco2Fhxj1wMbcz3A9LKJ DreBgdr/fUGSDTNETbqw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lssAe-00FqsU-G5; Mon, 14 Jun 2021 19:22:52 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lssAO-00Fqpn-Ha for linux-arm-kernel@lists.infradead.org; Mon, 14 Jun 2021 19:22:37 +0000 Received: from mail-ed1-f72.google.com ([209.85.208.72]) by youngberry.canonical.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1lssAM-0007v0-Ut for linux-arm-kernel@lists.infradead.org; Mon, 14 Jun 2021 19:22:35 +0000 Received: by mail-ed1-f72.google.com with SMTP id u26-20020a05640207dab02903935beb5c71so15007500edy.3 for ; Mon, 14 Jun 2021 12:22:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=v40f0IMWX+9KE3fNiPgtmRZ6Kg5WkPKxY6VfG/sZNRE=; b=sgOSwjo9zXs4EyUOy6eA0jC249W6syRS8waggtSdWb8Dnxo9ymLJDmJ1sJAG7FJhwv Q4cBT52HJ1BK3u7h6mHzQYPPNNc9jduwPjd5RsYMY2VjRQuDd29MzNpJhrUbTggpY17T dtmXFVRD7to9+P/Q5EmBRKDISCqOCf2uIsOYiJpo8BHyVqeHX7iDmwK1fjQWCNTqtyek w0amHj1s4xivU/ZsJpT4xXNvTabDCb25lkU/zZlA9WK3J32AW3g9ajuapIRhp9lPqbct yTIhH74Fye4mxwKfOpgwxW2TvdJ2DQlg5N5zVA20uoVS8yGdEf8cTIla5jbCpH1Gn+7A zOUQ== X-Gm-Message-State: AOAM533IeyavXbVyvCkYvwnfNAO/oGntLEI3EuC0gJbmi5sRd16N12Am wFuMkFBoirqqjIlDi2WkJ62FRc2W2m6zJcWB7i+dYetyw6FwZm6kgKs4CJonWbCPDc0DOf3sfgq 3ShVHZN8+KaWr4jwhJBStxxXV5pDL7eC0b/W1c5WXDNCWp4Fa318r X-Received: by 2002:a05:6402:1111:: with SMTP id u17mr19112856edv.87.1623698554628; Mon, 14 Jun 2021 12:22:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzGsYd69QUu+wFqDQnnw+BdpeP2+5cS8DUuCzeANpDr3eNbkYiQwXJf7g8EICQsTP83XB2tBQ== X-Received: by 2002:a05:6402:1111:: with SMTP id u17mr19112845edv.87.1623698554460; Mon, 14 Jun 2021 12:22:34 -0700 (PDT) Received: from localhost.localdomain (xdsl-188-155-177-222.adslplus.ch. [188.155.177.222]) by smtp.gmail.com with ESMTPSA id n23sm9071365edr.46.2021.06.14.12.22.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jun 2021 12:22:34 -0700 (PDT) From: Krzysztof Kozlowski To: Zhang Rui , Daniel Lezcano , Amit Kucheria , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Orson Zhai , Baolin Wang , Chunyan Zhang , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Krzysztof Kozlowski Subject: [PATCH v2 2/2] thermal: sprd: add missing of_node_put for loop iteration Date: Mon, 14 Jun 2021 21:22:30 +0200 Message-Id: <20210614192230.19248-2-krzysztof.kozlowski@canonical.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210614192230.19248-1-krzysztof.kozlowski@canonical.com> References: <20210614192230.19248-1-krzysztof.kozlowski@canonical.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210614_122236_631598_2941C886 X-CRM114-Status: GOOD ( 14.74 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Early exits from for_each_available_child_of_node() should decrement the node reference counter. Reported by Coccinelle: drivers/thermal/sprd_thermal.c:387:1-23: WARNING: Function "for_each_child_of_node" should have of_node_put() before goto around lines 391. Signed-off-by: Krzysztof Kozlowski Acked-by: Chunyan Zhang --- Changes since v1: 1. Add of_put label as suggested by Daniel. --- drivers/thermal/sprd_thermal.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/thermal/sprd_thermal.c b/drivers/thermal/sprd_thermal.c index 3682edb2f466..76a2caa9c265 100644 --- a/drivers/thermal/sprd_thermal.c +++ b/drivers/thermal/sprd_thermal.c @@ -388,7 +388,7 @@ static int sprd_thm_probe(struct platform_device *pdev) sen = devm_kzalloc(&pdev->dev, sizeof(*sen), GFP_KERNEL); if (!sen) { ret = -ENOMEM; - goto disable_clk; + goto of_put; } sen->data = thm; @@ -397,13 +397,13 @@ static int sprd_thm_probe(struct platform_device *pdev) ret = of_property_read_u32(sen_child, "reg", &sen->id); if (ret) { dev_err(&pdev->dev, "get sensor reg failed"); - goto disable_clk; + goto of_put; } ret = sprd_thm_sensor_calibration(sen_child, thm, sen); if (ret) { dev_err(&pdev->dev, "efuse cal analysis failed"); - goto disable_clk; + goto of_put; } sprd_thm_sensor_init(thm, sen); @@ -416,19 +416,20 @@ static int sprd_thm_probe(struct platform_device *pdev) dev_err(&pdev->dev, "register thermal zone failed %d\n", sen->id); ret = PTR_ERR(sen->tzd); - goto disable_clk; + goto of_put; } thm->sensor[sen->id] = sen; } + /* sen_child set to NULL at this point */ ret = sprd_thm_set_ready(thm); if (ret) - goto disable_clk; + goto of_put; ret = sprd_thm_wait_temp_ready(thm); if (ret) - goto disable_clk; + goto of_put; for (i = 0; i < thm->nr_sensors; i++) sprd_thm_toggle_sensor(thm->sensor[i], true); @@ -436,6 +437,8 @@ static int sprd_thm_probe(struct platform_device *pdev) platform_set_drvdata(pdev, thm); return 0; +of_put: + of_node_put(sen_child); disable_clk: clk_disable_unprepare(thm->clk); return ret;