Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 586B7C678DB for ; Mon, 6 Mar 2023 03:40:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229567AbjCFDko (ORCPT ); Sun, 5 Mar 2023 22:40:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229457AbjCFDkl (ORCPT ); Sun, 5 Mar 2023 22:40:41 -0500 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 21385F764 for ; Sun, 5 Mar 2023 19:40:38 -0800 (PST) Received: from loongson.cn (unknown [10.20.42.35]) by gateway (Coremail) with SMTP id _____8AxII+zYAVkeZ4IAA--.10622S3; Mon, 06 Mar 2023 11:40:35 +0800 (CST) Received: from [10.20.42.35] (unknown [10.20.42.35]) by localhost.localdomain (Coremail) with SMTP id AQAAf8BxSL2zYAVkmuhLAA--.1545S3; Mon, 06 Mar 2023 11:40:35 +0800 (CST) Subject: Re: [PATCH v2] drivers: loongson: fix memory leak in loongson2_guts_probe To: Dongliang Mu Cc: loongarch@lists.linux.dev, linux-kernel@vger.kernel.org References: <20230306025308.248987-1-dzm91@hust.edu.cn> From: zhuyinbo Message-ID: Date: Mon, 6 Mar 2023 11:40:35 +0800 User-Agent: Mozilla/5.0 (X11; Linux loongarch64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <20230306025308.248987-1-dzm91@hust.edu.cn> Content-Type: text/plain; charset=gbk; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-CM-TRANSID: AQAAf8BxSL2zYAVkmuhLAA--.1545S3 X-CM-SenderInfo: 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KxVWUJVW8JbIYCTnIWIevJa73UjIFyTuYvjxUzNtxUUUUU Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Tested-by: Yinbo Zhu ?? 2023/3/6 ????10:53, Dongliang Mu ะด??: > drivers/soc/loongson/loongson2_guts.c:150 loongson2_guts_probe() > warn: 'guts->regs' from ioremap() not released on lines: 131,135,139,143. > > Fix this by modifying ioremap to devm_ioremap. > > Note that, this patch is not tested due to the loongson architecture. > > Signed-off-by: Dongliang Mu > --- > v1->v2: instead of modifying error handling code, directly change > ioremap to devm_ioremap. > drivers/soc/loongson/loongson2_guts.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/soc/loongson/loongson2_guts.c b/drivers/soc/loongson/loongson2_guts.c > index bace4bc8e03b..a053e3fdae09 100644 > --- a/drivers/soc/loongson/loongson2_guts.c > +++ b/drivers/soc/loongson/loongson2_guts.c > @@ -107,7 +107,7 @@ static int loongson2_guts_probe(struct platform_device *pdev) > guts->little_endian = of_property_read_bool(np, "little-endian"); > > res = platform_get_resource(pdev, IORESOURCE_MEM, 0); > - guts->regs = ioremap(res->start, res->end - res->start + 1); > + guts->regs = devm_ioremap(dev, res->start, res->end - res->start + 1); > if (IS_ERR(guts->regs)) > return PTR_ERR(guts->regs); >