Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5083359rwl; Mon, 10 Apr 2023 23:38:15 -0700 (PDT) X-Google-Smtp-Source: AKy350YekAmPl9YUjh7m/c3q1U2epQcdnwe8lE7X8/HXkA0MdVRJ7qyCSpx2GTYdlXYfDBdAxb+E X-Received: by 2002:a17:90b:4a8d:b0:246:974d:ca4b with SMTP id lp13-20020a17090b4a8d00b00246974dca4bmr8878853pjb.32.1681195094796; Mon, 10 Apr 2023 23:38:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681195094; cv=none; d=google.com; s=arc-20160816; b=bvv7+CDcLKLcb4uCa960vczfJw3+aOcc2AKwZWgJk9F7h/6b8A+jSew62l9jc8pMAb vGbOQGrnr0doBdNGy3H2fswWXkm31cgpT+CWhPMj6A0ivysbfwKrWihGnBvwZY50+fbs c3md/Zp/KqzRVhg7wOpeSoBa/Se0om2++7XSvvmPDX47pM+cw7BdfhPhSfFXCeRzWq1j 1ZGO7RttWOBLg1+6OuE9Jzf2HY5jAS19g7bDI3M92owbw6CBq/opXmyHecC4VKSkoqQ9 x9a5NB4M5W1/iL7uRhbhm/hxJcFIjow8PgC/q1fiTh5N9VKMhSXNs/EPnCkhRJy3+EIj ytsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=E8FIj8gcn52CsRCrqw7Z9NlovazO6/iYMueu/ttWtsU=; b=gWKvneUl+/ka3l7GHQM8Dy0Bcs3KI6Q15e6ortfNO1DvsPUHK3ki4LUpaBmYAHuxhS 4D0dlnYEyIMFMVXZICx4x6FBD1Lc6MlIYoy9be42m+Vn5bELCIn0Dz+yGoZXosvJeTXH WvNj//ghk6AcsUu4wAUIiCcnPYYYiiuk934AYdCql6O1Vn42+1FbQXppfIj6W9Nc0+B+ bUKVloreX1IbD8H38TWb3fuRUQEJE0oa8Y6tm7omvLKEIW7KWAJcPiSer0Sx8oOdtlYa w61YsenT96v46Eoc2mNE2N9fF6laiaUsveaqwNbzWaL2NmFYdYBRNq8Hs/fX3iV6vBVt Y21A== 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 l15-20020a17090b078f00b00244b2d4a0e2si10671035pjz.22.2023.04.10.23.38.02; Mon, 10 Apr 2023 23:38:14 -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 S230282AbjDKGhu (ORCPT + 99 others); Tue, 11 Apr 2023 02:37:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229910AbjDKGht (ORCPT ); Tue, 11 Apr 2023 02:37:49 -0400 Received: from hust.edu.cn (unknown [202.114.0.240]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 510D91BF0; Mon, 10 Apr 2023 23:37:44 -0700 (PDT) Received: from passwd123-ThinkStation-P920.. ([222.20.94.23]) (user=void0red@hust.edu.cn mech=LOGIN bits=0) by mx1.hust.edu.cn with ESMTP id 33B6ZWKa016709-33B6ZWKb016709 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 11 Apr 2023 14:35:32 +0800 From: Kang Chen To: daniel.lezcano@linaro.org Cc: amitk@kernel.org, angelogioacchino.delregno@collabora.com, bchihi@baylibre.com, daniel@makrotopia.org, dzm91@hust.edu.cn, error27@gmail.com, henry.yen@mediatek.com, hust-os-kernel-patches@googlegroups.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-pm@vger.kernel.org, matthias.bgg@gmail.com, rafael@kernel.org, rdunlap@infradead.org, rui.zhang@intel.com, void0red@gmail.com, void0red@hust.edu.cn Subject: [PATCH v3 1/2] thermal: mediatek: use devm_of_iomap to avoid resource leak in mtk_thermal_probe Date: Tue, 11 Apr 2023 14:35:30 +0800 Message-Id: <20230411063531.3976354-1-void0red@hust.edu.cn> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-FEAS-AUTH-USER: void0red@hust.edu.cn X-Spam-Status: No, score=-0.0 required=5.0 tests=SPF_HELO_PASS,SPF_PASS autolearn=unavailable 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 Smatch reports: 1. mtk_thermal_probe() warn: 'apmixed_base' from of_iomap() not released. 2. mtk_thermal_probe() warn: 'auxadc_base' from of_iomap() not released. The original code forgets to release iomap resource when handling errors, fix it by switch to devm_of_iomap. Fixes: 89945047b166 ("thermal: mediatek: Add tsensor support for V2 thermal system") Signed-off-by: Kang Chen Reviewed-by: Dongliang Mu --- v3 -> v2: fix typo and put of_node in error handling v2 -> v1: use devm_of_iomap instead. drivers/thermal/mediatek/auxadc_thermal.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/mediatek/auxadc_thermal.c b/drivers/thermal/mediatek/auxadc_thermal.c index ab730f9552d0..3372f7c29626 100644 --- a/drivers/thermal/mediatek/auxadc_thermal.c +++ b/drivers/thermal/mediatek/auxadc_thermal.c @@ -1142,7 +1142,12 @@ static int mtk_thermal_probe(struct platform_device *pdev) return -ENODEV; } - auxadc_base = of_iomap(auxadc, 0); + auxadc_base = devm_of_iomap(&pdev->dev, auxadc, 0, NULL); + if (IS_ERR(auxadc_base)) { + of_node_put(auxadc); + return PTR_ERR(auxadc_base); + } + auxadc_phys_base = of_get_phys_base(auxadc); of_node_put(auxadc); @@ -1158,7 +1163,12 @@ static int mtk_thermal_probe(struct platform_device *pdev) return -ENODEV; } - apmixed_base = of_iomap(apmixedsys, 0); + apmixed_base = devm_of_iomap(&pdev->dev, apmixedsys, 0, NULL); + if (IS_ERR(apmixed_base)) { + of_node_put(apmixedsys); + return PTR_ERR(apmixed_base); + } + apmixed_phys_base = of_get_phys_base(apmixedsys); of_node_put(apmixedsys); -- 2.34.1