On Thu, 14 Dec 2017 07:03:49 +0100
Christophe JAILLET <christophe.jail...@wanadoo.fr> 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 <christophe.jail...@wanadoo.fr>
> ---
> 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;
>  };

Reply via email to