Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp3984496rwe; Mon, 17 Apr 2023 06:31:19 -0700 (PDT) X-Google-Smtp-Source: AKy350Z2GBPbANgVkdltlbPbhPL8OoU6gYiy4jFCkHC2sHhnACf1i8Nm0uSEzcPP06JjEA0P7Jda X-Received: by 2002:a05:6a20:cc46:b0:e9:353a:120 with SMTP id hq6-20020a056a20cc4600b000e9353a0120mr12323673pzb.15.1681738279303; Mon, 17 Apr 2023 06:31:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681738279; cv=none; d=google.com; s=arc-20160816; b=XekR8sDObyyHjnpZt+PdY0y7tdJD0pZw05hnRURs0Id6FnzIiKWkaiaDGgHtjORswv xgfz0mOfkfKL4sL7qVdzCdkfeMHnKFCTY8SbCpHYO9cEuZ5wy9CZ67EFsHBIxOawQQi9 21UY89h86QSo/l8Vk0IRxU/BduoTjobCNib+PrfJLj21psfr1wpPqVMLazwp9SqtCTfe kXL3L5ADSiF/WTuFG8RKkjf8tQiJV+gNKd2FKz6/HhuwRZ/lb6PDPHuGLKT3gIDl2btt oPjzPxP7+XMC4A26Y1inXybjiOWbTGvoQYymSizCY1YsVspHA1ZMMW4vL+7oMufa/cZW 4Ctw== 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=yEOWscDWDfmed4l1GEB49C3oJ45zys/kaGrzyybRUpI=; b=gioAHDSCGZItCA3ZxwvjvXmdbkhoxJVXO/bljmHSj6j37uGwvTHpGnuLqrFEAz1wdp xBX2p412kxTQNLTgFdV87xuz9QsvZFvCUWt8LhKYjYPOVBTn2EVx5FDKdkJ/7Oyx9ns7 JBzf9GO+Y/Nzvb88G0f/NWsZql3H68g30/Q3ZLf/KQ/uqC9jOWfS8n3rHfUt0wdQ/Sl9 5aEM2MjMxK+H8DhpBG17UGbb2rMrFDurBYdlqzFD/MTXGu63hlipZFuqUQZmuC/QGisq fvsQMLePy8GUKtzVoZU0GzE/Fg4UlbDu2/M8IdDNib4Qafki1uZCOhWEUEm1rxVzyuZv qczw== 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 t190-20020a6381c7000000b00517a80b4245si10733022pgd.756.2023.04.17.06.31.00; Mon, 17 Apr 2023 06:31:19 -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 S229909AbjDQNW7 (ORCPT + 99 others); Mon, 17 Apr 2023 09:22:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229548AbjDQNW6 (ORCPT ); Mon, 17 Apr 2023 09:22:58 -0400 Received: from hust.edu.cn (mail.hust.edu.cn [202.114.0.240]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BA50B0; Mon, 17 Apr 2023 06:22:56 -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 33HCtsCs000971-33HCtsCt000971 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 17 Apr 2023 20:55:54 +0800 From: Kang Chen To: error27@gmail.com Cc: amitk@kernel.org, angelogioacchino.delregno@collabora.com, bchihi@baylibre.com, daniel.lezcano@linaro.org, daniel@makrotopia.org, dzm91@hust.edu.cn, 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 v4 1/2] thermal: mediatek: use devm_of_iomap to avoid resource leak in mtk_thermal_probe Date: Mon, 17 Apr 2023 20:55:32 +0800 Message-Id: <20230417125533.3142236-1-void0red@hust.edu.cn> X-Mailer: git-send-email 2.34.1 In-Reply-To: <48ae0e2e-257d-4ad2-afbc-2eb4b48e516b@kili.mountain> References: <48ae0e2e-257d-4ad2-afbc-2eb4b48e516b@kili.mountain> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-FEAS-AUTH-USER: void0red@hust.edu.cn X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, 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 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 --- v4 -> v3: no modify 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 b6bb9eaafb74..dcc64237ea60 100644 --- a/drivers/thermal/mediatek/auxadc_thermal.c +++ b/drivers/thermal/mediatek/auxadc_thermal.c @@ -1212,7 +1212,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); @@ -1228,7 +1233,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