Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1062765pxf; Thu, 8 Apr 2021 21:54:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwF27TT4UnGtzSDiqle8CRrMkSgPem/52jYb98HQvFvbXfLQ5LoTHilO3/aPfyHSz5MrV32 X-Received: by 2002:a62:ee0c:0:b029:214:7a61:6523 with SMTP id e12-20020a62ee0c0000b02902147a616523mr10706763pfi.59.1617944097190; Thu, 08 Apr 2021 21:54:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617944097; cv=none; d=google.com; s=arc-20160816; b=ODa7V4tm6hXAUJRlaKnEUfQgWIqN9Kvgqkzcgs3LS1tHSY42k8VRvOGvL38ajJzh56 LZas/itovafCsbswWOXj54lBg7ns2xmbT3DNh5TcK28375maTvLgbXSfAwgoAIFQPguk X5jvTU2qvaeHIJVb17UlRm609b8ci/Xse00tRRgPcZjYUlf0qqktNXfJcKethSOGb2G8 8b2G8PtPwVvkgLJb++fnLyv/wuveC0CC+H1XiBBVefwkl++FzSR4ZA8fH2gcyQ8E4YZq xAoN+ajhiklvHttPFFke3DMKLgtTPjxP/Wuc+wDu0FknprxC9qM/yr98a3VWnDKx2vKp nxPA== 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 :message-id:date:subject:cc:to:from; bh=sFfn9KML1Ps9YgQLKVuFikCZL8/3Id6FBN95FNJzwEI=; b=G3/aCwc2cYdGVfNL2JrcKTEJNx1Xwwd8A5xLzKztcezQNscob5+U6l9imaHYgbTR0Q pkXF1ff3/E4ulAzTgc/NqDxGCAtyUC3oLiJyboSBB7zpTPnlcDZry5EOlHuL7I4MHe8C u1LzdEktmxvbxErwrzKTzwVZiFpxDPbDm5C4eOFrfXIyxMdjjxCrgg/jCoipGyjHelTF sKYM//4uAl7aUbgmeWl6lLPyMWyXMQiBpuAO+9ULnAOKRWfpwO28uPILxXxyA02ZkWvH 2/2ZK/aXJJkK0qZ7lG6xPkG0//K0WRo1B1HkugydvsUqITsgxFRX1lNFw7mQdmEjgh9r X7RA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r17si1685390pjp.165.2021.04.08.21.54.44; Thu, 08 Apr 2021 21:54:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229840AbhDIExq (ORCPT + 99 others); Fri, 9 Apr 2021 00:53:46 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:16425 "EHLO szxga06-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230312AbhDIExo (ORCPT ); Fri, 9 Apr 2021 00:53:44 -0400 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4FGm1p336wzlWqH; Fri, 9 Apr 2021 12:51:42 +0800 (CST) Received: from huawei.com (10.175.103.91) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.498.0; Fri, 9 Apr 2021 12:53:25 +0800 From: Yang Yingliang To: , CC: , , Subject: [PATCH -next] clocksource/drivers/qcom: add missing iounmap() on error in msm_dt_timer_init() Date: Fri, 9 Apr 2021 12:56:57 +0800 Message-ID: <20210409045657.666888-1-yangyingliang@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.103.91] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org base and cpu0_base are not unmapped on error path, add the missing iounmap() before return msm_dt_timer_init() in the error handling cases. Fixes: 6e3321631ac2 ("ARM: msm: Add DT support to msm_timer") Reported-by: Hulk Robot Signed-off-by: Yang Yingliang --- drivers/clocksource/timer-qcom.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/drivers/clocksource/timer-qcom.c b/drivers/clocksource/timer-qcom.c index b4afe3a67583..3488876198e0 100644 --- a/drivers/clocksource/timer-qcom.c +++ b/drivers/clocksource/timer-qcom.c @@ -213,7 +213,8 @@ static int __init msm_dt_timer_init(struct device_node *np) irq = irq_of_parse_and_map(np, 1); if (irq <= 0) { pr_err("Can't get irq\n"); - return -EINVAL; + ret = -EINVAL; + goto err_unmap_base; } /* We use CPU0's DGT for the clocksource */ @@ -223,18 +224,19 @@ static int __init msm_dt_timer_init(struct device_node *np) ret = of_address_to_resource(np, 0, &res); if (ret) { pr_err("Failed to parse DGT resource\n"); - return ret; + goto err_unmap_base; } cpu0_base = ioremap(res.start + percpu_offset, resource_size(&res)); if (!cpu0_base) { pr_err("Failed to map source base\n"); - return -EINVAL; + goto err_unmap_base; } if (of_property_read_u32(np, "clock-frequency", &freq)) { pr_err("Unknown frequency\n"); - return -EINVAL; + ret = -EINVAL; + goto err_unmap_cpu0_base; } event_base = base + 0x4; @@ -243,7 +245,18 @@ static int __init msm_dt_timer_init(struct device_node *np) freq /= 4; writel_relaxed(DGT_CLK_CTL_DIV_4, source_base + DGT_CLK_CTL); - return msm_timer_init(freq, 32, irq, !!percpu_offset); + ret = msm_timer_init(freq, 32, irq, !!percpu_offset); + if (ret) + goto err_unmap_cpu0_base; + + return 0; + +err_unmap_cpu0_base: + iounmap(cpu0_base); +err_unmap_base: + iounmap(base); + + return ret; } TIMER_OF_DECLARE(kpss_timer, "qcom,kpss-timer", msm_dt_timer_init); TIMER_OF_DECLARE(scss_timer, "qcom,scss-timer", msm_dt_timer_init); -- 2.25.1