Message ID | 20230306025308.248987-1-dzm91@hust.edu.cn |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1629353wrd; Sun, 5 Mar 2023 18:59:56 -0800 (PST) X-Google-Smtp-Source: AK7set8zNTX4NsUbXMLmaWoD6ipKriTZFExP6NFgaayzmDhRpMAmPHsAQloJCZYNL4e/sDN9uI5p X-Received: by 2002:a17:90b:4c02:b0:23a:ad68:25a9 with SMTP id na2-20020a17090b4c0200b0023aad6825a9mr2365481pjb.43.1678071595884; Sun, 05 Mar 2023 18:59:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678071595; cv=none; d=google.com; s=arc-20160816; b=OebWAwA961WL62V7ml+lcYyUXyBZl9GBzqx9m8qD+tuazSL1ui8G9YLQCOAUoW8PW+ t6qqzpI6iIsjtKA4PbOhKGhQzovgdpR+r4DoCrMMWHH12i/wQ95ScsNYgF7I7TOqDW1Y 4TYW0UvgSUAV7ZeHcaDUw8eugDuT1yckKZS2YhNAJd5YoSJ40RZsSDGYxwPZlXN55jy1 kdqDJYzoTs7SwRLpFsj7yM2gYAVEmSs8efgAuCC8IwkL+jkxaaM8NPwxdpW9DOstDJ13 UjWzs8iMW+hIIq5ITo9PhvQOfpy6+z+G3Iwo1zLThBPR34BxBGBQUY6AarzM3QpQtVH2 dSBA== 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=1er4G55iDIv8dOQbyT3zX4TfFHX5BXcYQJ1CMJ5IpuE=; b=iXjkdQjzZ8g81lPIcdS5NYyrwHk2V+UXDuuhGx2ayCtgR0BvWhNgkYg9CCNV0N20wW g4Qz1w9zEl9iJSWoNfsIQ1jxyzTuupcANINRaY3AlRZCZiMnAuMVprYORUmSQEUWggCL pRJd+YqjaF+LdtbLbRdjqKg/XJphjTPhkLIi/zCdRYdM4/wN5v45B3Tof0U9BIhTBK04 lvmPpS1IVRFfvkQyJplIUTXip/Obzj6JhhJDRJf/Fe5z+JEadF8pcicS3TgGuWV/rkFe W7rtZI0AjKPPg5MC+DHnmrtE7DThKFKrR4rbKIByQb2Jr55yQBGGZjgDC4X+dp48LZxs mmwg== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x5-20020a654145000000b0050308cba875si7976368pgp.490.2023.03.05.18.59.43; Sun, 05 Mar 2023 18:59:55 -0800 (PST) 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 S229556AbjCFC4B (ORCPT <rfc822;carlos.wei.hk@gmail.com> + 99 others); Sun, 5 Mar 2023 21:56:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229579AbjCFCz7 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 5 Mar 2023 21:55:59 -0500 Received: from hust.edu.cn (unknown [202.114.0.240]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAC9312874 for <linux-kernel@vger.kernel.org>; Sun, 5 Mar 2023 18:55:58 -0800 (PST) Received: from localhost.localdomain ([172.16.0.254]) (user=dzm91@hust.edu.cn mech=LOGIN bits=0) by mx1.hust.edu.cn with ESMTP id 3262thtC003642-3262thtF003642 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 6 Mar 2023 10:55:47 +0800 From: Dongliang Mu <dzm91@hust.edu.cn> To: Yinbo Zhu <zhuyinbo@loongson.cn> Cc: Dongliang Mu <dzm91@hust.edu.cn>, loongarch@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v2] drivers: loongson: fix memory leak in loongson2_guts_probe Date: Mon, 6 Mar 2023 10:53:07 +0800 Message-Id: <20230306025308.248987-1-dzm91@hust.edu.cn> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-FEAS-AUTH-USER: dzm91@hust.edu.cn X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759585601470175414?= X-GMAIL-MSGID: =?utf-8?q?1759585601470175414?= |
Series |
[v2] drivers: loongson: fix memory leak in loongson2_guts_probe
|
|
Commit Message
Dongliang Mu
March 6, 2023, 2:53 a.m. UTC
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 <dzm91@hust.edu.cn>
---
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(-)
Comments
Reviewed-by: Huacai Chen <chenhuacai@loongson.cn> On Mon, Mar 6, 2023 at 10:55 AM Dongliang Mu <dzm91@hust.edu.cn> 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 <dzm91@hust.edu.cn> > --- > 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); > > -- > 2.39.2 > >
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 <dzm91@hust.edu.cn> > --- > 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. > if (IS_ERR(guts->regs)) > return PTR_ERR(guts->regs); > Otherwise LGTM, thanks! Untested by me though, Reviewed-by: WANG Xuerui <git@xen0n.name>
> On Mar 6, 2023, at 11:03, WANG Xuerui <kernel@xen0n.name> 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 <dzm91@hust.edu.cn> >> --- >> 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 <git@xen0n.name> > > -- > WANG "xen0n" Xuerui > > Linux/LoongArch mailing list: https://lore.kernel.org/loongarch/
Tested-by: Yinbo Zhu <zhuyinbo@loongson.cn> 在 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 <dzm91@hust.edu.cn> > --- > 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); >
Hi, Dongliang, Reviewed-by: Huacai Chen <chenhuacai@loongson.cn> And please resend this patch with title "soc: loongson: fix memory leak in loongson2_guts_probe()", cc Arnd and soc@kernel.org, because that is the most appropriate list for this patch. Huacai On Mon, Mar 6, 2023 at 10:55 AM Dongliang Mu <dzm91@hust.edu.cn> 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 <dzm91@hust.edu.cn> > --- > 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); > > -- > 2.39.2 > >
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);