From: Boris Brezillon <boris.brezillon@free-electrons.com>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
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
Date: Mon, 18 Dec 2017 21:03:08 +0100 [thread overview]
Message-ID: <20171218210308.791fb0ae@bbrezillon> (raw)
In-Reply-To: <f223e9ea768198b70e37102fc369007d1482e802.1513230484.git.christophe.jaillet@wanadoo.fr>
On Thu, 14 Dec 2017 07:03:49 +0100
Christophe JAILLET <christophe.jaillet@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.jaillet@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;
> };
next prev parent reply other threads:[~2017-12-18 20:03 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-14 6:03 [PATCH 0/4 v3] mtd: onenand: samsung: Simplify code and fix leaks in error handling paths Christophe JAILLET
2017-12-14 6:03 ` [PATCH 1/4 v3] mtd: onenand: samsung: use devm_ function to simplify code and fix some leaks Christophe JAILLET
2017-12-18 20:03 ` Boris Brezillon [this message]
2017-12-14 6:03 ` [PATCH 2/4 v3] mtd: onenand: samsung: return an error if 'mtd_device_parse_register()' fails Christophe JAILLET
2017-12-14 6:03 ` [PATCH 3/4 v3] mtd: onenand: samsung: Propagate the error returned by 'onenand_scan()' Christophe JAILLET
2017-12-14 6:03 ` [PATCH 3/4 v3] mtd: onenand: samsung: Remove a useless include Christophe JAILLET
2017-12-18 19:58 ` Boris Brezillon
2017-12-18 20:03 ` [PATCH 0/4 v3] mtd: onenand: samsung: Simplify code and fix leaks in error handling paths Boris Brezillon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171218210308.791fb0ae@bbrezillon \
--to=boris.brezillon@free-electrons.com \
--cc=christophe.jaillet@wanadoo.fr \
--cc=computersforpeace@gmail.com \
--cc=cyrille.pitchen@wedev4u.fr \
--cc=dwmw2@infradead.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=kyungmin.park@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=marek.vasut@gmail.com \
--cc=richard@nod.at \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox