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 6E38FC61DA4 for ; Mon, 6 Mar 2023 03:20:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229754AbjCFDUU convert rfc822-to-8bit (ORCPT ); Sun, 5 Mar 2023 22:20:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229625AbjCFDUS (ORCPT ); Sun, 5 Mar 2023 22:20:18 -0500 Received: from hust.edu.cn (unknown [202.114.0.240]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D62793DC for ; Sun, 5 Mar 2023 19:20:17 -0800 (PST) Received: from smtpclient.apple ([172.16.0.254]) (user=dzm91@hust.edu.cn mech=PLAIN bits=0) by mx1.hust.edu.cn with ESMTP id 3263K5qV006092-3263K5qX006092 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 6 Mar 2023 11:20:05 +0800 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.2\)) Subject: Re: [PATCH v2] drivers: loongson: fix memory leak in loongson2_guts_probe From: Dongliang Mu In-Reply-To: Date: Mon, 6 Mar 2023 11:20:05 +0800 Cc: Yinbo Zhu , loongarch@lists.linux.dev, linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: <7AEE1E65-5A60-45DB-B2BA-AADB2711356C@hust.edu.cn> References: <20230306025308.248987-1-dzm91@hust.edu.cn> To: WANG Xuerui X-Mailer: Apple Mail (2.3696.120.41.1.2) X-FEAS-AUTH-USER: dzm91@hust.edu.cn Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Mar 6, 2023, at 11:03, WANG Xuerui wrote: > > On 2023/3/6 10:53, Dongliang Mu wrote: >> 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); > > resource_size(res) is exactly "res->end - res->start + 1", you may use that to simplify code now that you touched this line. I will send a v3 patch since this is a good suggestion. > >> if (IS_ERR(guts->regs)) >> return PTR_ERR(guts->regs); >> > > Otherwise LGTM, thanks! Untested by me though, > > Reviewed-by: WANG Xuerui > > -- > WANG "xen0n" Xuerui > > Linux/LoongArch mailing list: https://lore.kernel.org/loongarch/