Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933318AbdLRUDh (ORCPT ); Mon, 18 Dec 2017 15:03:37 -0500 Received: from mail.free-electrons.com ([62.4.15.54]:34329 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757063AbdLRUDf (ORCPT ); Mon, 18 Dec 2017 15:03:35 -0500 Date: Mon, 18 Dec 2017 21:03:08 +0100 From: Boris Brezillon To: Christophe JAILLET Cc: kyungmin.park@samsung.com, dwmw2@infradead.org, computersforpeace@gmail.com, marek.vasut@gmail.com, richard@nod.at, cyrille.pitchen@wedev4u.fr, linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH 1/4 v3] mtd: onenand: samsung: use devm_ function to simplify code and fix some leaks Message-ID: <20171218210308.791fb0ae@bbrezillon> In-Reply-To: References: X-Mailer: Claws Mail 3.14.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1687 Lines: 48 On Thu, 14 Dec 2017 07:03:49 +0100 Christophe JAILLET wrote: > Convert all error handling code in 's3c_onenand_probe()' to > resource-managed alternatives in order to simplify code. > > This fixes a resource leak if 'platform_get_resource()' fails at line 872. > > The 'request_irq()' at line 971 was also un-balanced. It is now > resource-managed. > > Signed-off-by: Christophe JAILLET > --- > Cross-compiled tested-only > > v2: use devm_ioremap_resource() > v3: fix a bug introduced in v2 > --- > drivers/mtd/onenand/samsung.c | 164 ++++++++---------------------------------- > 1 file changed, 29 insertions(+), 135 deletions(-) > > diff --git a/drivers/mtd/onenand/samsung.c b/drivers/mtd/onenand/samsung.c > index af0ac1a7bf8f..b650290611d2 100644 > --- a/drivers/mtd/onenand/samsung.c > +++ b/drivers/mtd/onenand/samsung.c > @@ -129,16 +129,13 @@ struct s3c_onenand { > struct platform_device *pdev; > enum soc_type type; > void __iomem *base; > - struct resource *base_res; > void __iomem *ahb_addr; > - struct resource *ahb_res; > int bootram_command; > void __iomem *page_buf; > void __iomem *oob_buf; Next thing to address: page_buf and oob_buf are not iomem regions (they are allocated with kmalloc) and should not have an __iomem specifier. You should also get rid of the various casts transforming those iomem pointers into regular ones. > unsigned int (*mem_addr)(int fba, int fpa, int fsa); > unsigned int (*cmd_map)(unsigned int type, unsigned int val); > void __iomem *dma_addr; > - struct resource *dma_res; > unsigned long phys_base; > struct completion complete; > };