Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp4123402ybz; Tue, 28 Apr 2020 06:14:02 -0700 (PDT) X-Google-Smtp-Source: APiQypJgw/iO6+HjInwzuEZoYi+ZAy03p1508v7WPnjc/lQNwgBm1AIH+yr47CvFLxn6GiHLz5VE X-Received: by 2002:a17:906:18a2:: with SMTP id c2mr17358920ejf.167.1588079642724; Tue, 28 Apr 2020 06:14:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588079642; cv=none; d=google.com; s=arc-20160816; b=Ui2SsoeVsru/zB+7MxkH6YqEjsj//UqAOVmEM7WkUnLAfV97vARE2E4qN44RvnCYcq iv760Sq8uUxGKcktyH6NMXmwijovbWZfSc9LVm9KdaYk9JOuasKcaBzhPPL1Y/S0z7gT 2jUHJayUmvzlE9bNrLqB2OKGrqt8TTLebYo/G3RuIET67NDWD/+XfIvjbJUKsyNLC1gr IUp8h9dp+ewqe9MGI1S1a/1QgwQPQlyuvpoh1KTNWV0qEtCvDQvjT/1Q/rPqWdC0KBAF Vh8oyCm8K0E8aNrls6w4xpiEMo6f2k+969iaEi0KZquneXC/WUeR305Do+Elns59OHPX +chA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=QY6myh2Pbs2C9PZFWtJrxYe9xeu5bPk92DtEEgzJ9PU=; b=j0D/6jigjegq632Bnk3uRzEweyWVXegcuEToWw5+sdsvQFTOece9G/Yk6E+IZ2cnKC 9lxkb7Fq5C5pKzkf9kX3jLrt71BEuY3WTAmURkk3jK5m7a6J3aGbMhok0tFqMRoSqD1s zJogieEhB0ULjns7I5pxBT/pYw5F5sWMB3IuJYpKYF2ShhQkyVNIFTtAeCEArRp5/diE 8TNm6hGFfMFi7rmA+g+l1Rlnpwtqv1MT6rD9Zc4wjJGviMgRtyhx2iPBRw9grG7aGkIk QUlft7lwy0dfdUvqfVSioHNzKagZb5V82qf3VdjipjpseH+0MXBi6GiumYHieU5E7Wrb ah9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=p1CIaXBa; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v15si1571481edq.394.2020.04.28.06.13.38; Tue, 28 Apr 2020 06:14:02 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=p1CIaXBa; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726862AbgD1NMG (ORCPT + 99 others); Tue, 28 Apr 2020 09:12:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726785AbgD1NMG (ORCPT ); Tue, 28 Apr 2020 09:12:06 -0400 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA362C03C1A9; Tue, 28 Apr 2020 06:12:05 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id x2so6950157pfx.7; Tue, 28 Apr 2020 06:12:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=QY6myh2Pbs2C9PZFWtJrxYe9xeu5bPk92DtEEgzJ9PU=; b=p1CIaXBa6jbtnD4pxqBpOM+KmW3HNVZ8XxHooyFDVvpLCPHQctJB43RB0PfDugQFSM fuiuSZxh2h8/B9giQEmv0u6wW4X1vARujgvHj3ipUagNBeSbKSzKIeG2SvYLoc5A1rEL 9EWQ7Xpd6ZAKrJIDiKp2hI6RvjP1pO35nvkMaKuWJtN+slLeIZLnuEFw8PECWABykSx4 mKLIRifGuMwQWkEHPemS6TQNbU0ipm/2VgOpHlaYKI3zoBNi3SW2zSTPW3xiBezZwbHk wJroKSNyyMRPDQTKmVCAj7k4/KPI05h8h84RDIScjlPc6SiBb4OCFc2mGk7zmakbGZEK rNrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=QY6myh2Pbs2C9PZFWtJrxYe9xeu5bPk92DtEEgzJ9PU=; b=Tt+uPjMCKd0WN7tvy13UpiE9kG1VIWhwYS2VNTUDJzvlG4ieUqdN4BdEI57dh+knZ3 uaVI3vl4MY/Xazvhh94OyB4V5xHzqlpfsSLbv0rHNHh7IQouu9tovrR0G2YiKHsn0Rcc 6fBqRVwmvSjJ/fJmjbBN7Aoci7jdp6dby8bNNFxAAWkp7NtFWxkdqe2wSZJ26jXXX0Y2 U0Fz42kiuSaWq54MyFUta6rsluf5OsRxFYUkQCo5zyBh1Y3DgayPc7dNU9IvyyCbOrR0 dM/YrydyoFgrb/0pqCHR3zyqtMNsbAmjgak77sIKH7f7nZwPWUl4vBsXMBouaTQ5IyhE 2VRA== X-Gm-Message-State: AGi0PubI3yzbc1B1iGcSlAF1cCo98Y952aNaOvkLEWnfBfb9F738PhRe q9mSS04icEZ9a1/C2+0o8vQ= X-Received: by 2002:a63:585c:: with SMTP id i28mr27952797pgm.363.1588079525423; Tue, 28 Apr 2020 06:12:05 -0700 (PDT) Received: from localhost ([89.208.244.169]) by smtp.gmail.com with ESMTPSA id x10sm13152720pgq.79.2020.04.28.06.12.04 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Apr 2020 06:12:05 -0700 (PDT) Date: Tue, 28 Apr 2020 21:11:59 +0800 From: Dejin Zheng To: Nicolas Ferre Cc: Andy Shevchenko , "David S. Miller" , Paul Walmsley , Palmer Dabbelt , yash.shah@sifive.com, netdev , Linux Kernel Mailing List , Claudiu Beznea Subject: Re: [PATCH net v1] net: macb: fix an issue about leak related system resources Message-ID: <20200428131159.GA2128@nuc8i5> References: <20200425125737.5245-1-zhengdejin5@gmail.com> <20200428032453.GA32072@nuc8i5> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 28, 2020 at 10:42:56AM +0200, Nicolas Ferre wrote: > On 28/04/2020 at 05:24, Dejin Zheng wrote: > > On Mon, Apr 27, 2020 at 01:33:41PM +0300, Andy Shevchenko wrote: > > > On Sat, Apr 25, 2020 at 3:57 PM Dejin Zheng wrote: > > > > > > > > A call of the function macb_init() can fail in the function > > > > fu540_c000_init. The related system resources were not released > > > > then. use devm_ioremap() to replace ioremap() for fix it. > > > > > > > > > > Why not to go further and convert to use devm_platform_ioremap_resource()? > > > > > devm_platform_ioremap_resource() will call devm_request_mem_region(), > > and here did not do it. > > And what about devm_platform_get_and_ioremap_resource()? This would > streamline this whole fu540_c000_init() function. > Nicolas, the function devm_platform_get_and_ioremap_resource() will also call devm_request_mem_region(), after call it, These IO addresses will be monopolized by this driver. the devm_ioremap() and ioremap() are not do this. if this IO addresses will be shared with the other driver, call devm_platform_get_and_ioremap_resource() may be fail. BR, Dejin > Regards, > Nicolas > > > > > Fixes: c218ad559020ff9 ("macb: Add support for SiFive FU540-C000") > > > > Cc: Andy Shevchenko > > > > Signed-off-by: Dejin Zheng > > > > --- > > > > drivers/net/ethernet/cadence/macb_main.c | 2 +- > > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > > > diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c > > > > index a0e8c5bbabc0..edba2eb56231 100644 > > > > --- a/drivers/net/ethernet/cadence/macb_main.c > > > > +++ b/drivers/net/ethernet/cadence/macb_main.c > > > > @@ -4178,7 +4178,7 @@ static int fu540_c000_init(struct platform_device *pdev) > > > > if (!res) > > > > return -ENODEV; > > > > > > > > - mgmt->reg = ioremap(res->start, resource_size(res)); > > > > + mgmt->reg = devm_ioremap(&pdev->dev, res->start, resource_size(res)); > > > > if (!mgmt->reg) > > > > return -ENOMEM; > > > > > > > -- > Nicolas Ferre