* [PATCH] spi: omap2-mcspi: fix omap2_mcspi_probe error handling
@ 2011-06-22 13:57 Axel Lin
2011-06-22 15:29 ` Grant Likely
0 siblings, 1 reply; 4+ messages in thread
From: Axel Lin @ 2011-06-22 13:57 UTC (permalink / raw)
To: linux-kernel; +Cc: Samuel Ortiz, Juha Yrjola, Grant Likely, spi-devel-general
This patch includes below fixes for error handling:
1. return proper error if kcalloc for mcspi->dma_channels fails
2. return proper error if omap2_mcspi_master_setup fails
3. properly release allocated resources in error paths and
improve the naming of goto labels.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
drivers/spi/spi-omap2-mcspi.c | 39 +++++++++++++++++++++------------------
1 files changed, 21 insertions(+), 18 deletions(-)
diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index fde3a2d..74f444d 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -1087,7 +1087,7 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev)
struct omap2_mcspi_platform_config *pdata = pdev->dev.platform_data;
struct omap2_mcspi *mcspi;
struct resource *r;
- int status = 0, i;
+ int status, i;
master = spi_alloc_master(&pdev->dev, sizeof *mcspi);
if (master == NULL) {
@@ -1114,12 +1114,12 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev)
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (r == NULL) {
status = -ENODEV;
- goto err1;
+ goto err_put_master;
}
if (!request_mem_region(r->start, resource_size(r),
dev_name(&pdev->dev))) {
status = -EBUSY;
- goto err1;
+ goto err_put_master;
}
r->start += pdata->regs_offset;
@@ -1129,7 +1129,7 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev)
if (!mcspi->base) {
dev_dbg(&pdev->dev, "can't ioremap MCSPI\n");
status = -ENOMEM;
- goto err2;
+ goto err_release_mem_region;
}
mcspi->dev = &pdev->dev;
@@ -1143,8 +1143,10 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev)
sizeof(struct omap2_mcspi_dma),
GFP_KERNEL);
- if (mcspi->dma_channels == NULL)
- goto err2;
+ if (mcspi->dma_channels == NULL) {
+ status = -ENOMEM;
+ goto err_iounmap;
+ }
for (i = 0; i < master->num_chipselect; i++) {
char dma_ch_name[14];
@@ -1156,7 +1158,7 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev)
if (!dma_res) {
dev_dbg(&pdev->dev, "cannot get DMA RX channel\n");
status = -ENODEV;
- break;
+ goto err_free_dma_channels;
}
mcspi->dma_channels[i].dma_rx_channel = -1;
@@ -1167,7 +1169,7 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev)
if (!dma_res) {
dev_dbg(&pdev->dev, "cannot get DMA TX channel\n");
status = -ENODEV;
- break;
+ goto err_free_dma_channels;
}
mcspi->dma_channels[i].dma_tx_channel = -1;
@@ -1176,23 +1178,24 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev)
pm_runtime_enable(&pdev->dev);
- if (status || omap2_mcspi_master_setup(mcspi) < 0)
- goto err3;
+ status = omap2_mcspi_master_setup(mcspi);
+ if (status)
+ goto err_free_dma_channels;
status = spi_register_master(master);
if (status < 0)
- goto err4;
+ goto err_free_dma_channels;
- return status;
+ return 0;
-err4:
- spi_master_put(master);
-err3:
+err_free_dma_channels:
kfree(mcspi->dma_channels);
-err2:
- release_mem_region(r->start, resource_size(r));
+err_iounmap:
iounmap(mcspi->base);
-err1:
+err_release_mem_region:
+ release_mem_region(r->start, resource_size(r));
+err_put_master:
+ spi_master_put(master);
return status;
}
--
1.7.4.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] spi: omap2-mcspi: fix omap2_mcspi_probe error handling
2011-06-22 13:57 [PATCH] spi: omap2-mcspi: fix omap2_mcspi_probe error handling Axel Lin
@ 2011-06-22 15:29 ` Grant Likely
2011-06-27 4:23 ` Axel Lin
0 siblings, 1 reply; 4+ messages in thread
From: Grant Likely @ 2011-06-22 15:29 UTC (permalink / raw)
To: Axel Lin; +Cc: linux-kernel, Samuel Ortiz, Juha Yrjola, spi-devel-general
On Wed, Jun 22, 2011 at 7:57 AM, Axel Lin <axel.lin@gmail.com> wrote:
> This patch includes below fixes for error handling:
> 1. return proper error if kcalloc for mcspi->dma_channels fails
> 2. return proper error if omap2_mcspi_master_setup fails
> 3. properly release allocated resources in error paths and
> improve the naming of goto labels.
Is this to be applied immediately, or queued up in linux-next for v3.1?
g.
>
> Signed-off-by: Axel Lin <axel.lin@gmail.com>
> ---
> drivers/spi/spi-omap2-mcspi.c | 39 +++++++++++++++++++++------------------
> 1 files changed, 21 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
> index fde3a2d..74f444d 100644
> --- a/drivers/spi/spi-omap2-mcspi.c
> +++ b/drivers/spi/spi-omap2-mcspi.c
> @@ -1087,7 +1087,7 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev)
> struct omap2_mcspi_platform_config *pdata = pdev->dev.platform_data;
> struct omap2_mcspi *mcspi;
> struct resource *r;
> - int status = 0, i;
> + int status, i;
>
> master = spi_alloc_master(&pdev->dev, sizeof *mcspi);
> if (master == NULL) {
> @@ -1114,12 +1114,12 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev)
> r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> if (r == NULL) {
> status = -ENODEV;
> - goto err1;
> + goto err_put_master;
> }
> if (!request_mem_region(r->start, resource_size(r),
> dev_name(&pdev->dev))) {
> status = -EBUSY;
> - goto err1;
> + goto err_put_master;
> }
>
> r->start += pdata->regs_offset;
> @@ -1129,7 +1129,7 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev)
> if (!mcspi->base) {
> dev_dbg(&pdev->dev, "can't ioremap MCSPI\n");
> status = -ENOMEM;
> - goto err2;
> + goto err_release_mem_region;
> }
>
> mcspi->dev = &pdev->dev;
> @@ -1143,8 +1143,10 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev)
> sizeof(struct omap2_mcspi_dma),
> GFP_KERNEL);
>
> - if (mcspi->dma_channels == NULL)
> - goto err2;
> + if (mcspi->dma_channels == NULL) {
> + status = -ENOMEM;
> + goto err_iounmap;
> + }
>
> for (i = 0; i < master->num_chipselect; i++) {
> char dma_ch_name[14];
> @@ -1156,7 +1158,7 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev)
> if (!dma_res) {
> dev_dbg(&pdev->dev, "cannot get DMA RX channel\n");
> status = -ENODEV;
> - break;
> + goto err_free_dma_channels;
> }
>
> mcspi->dma_channels[i].dma_rx_channel = -1;
> @@ -1167,7 +1169,7 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev)
> if (!dma_res) {
> dev_dbg(&pdev->dev, "cannot get DMA TX channel\n");
> status = -ENODEV;
> - break;
> + goto err_free_dma_channels;
> }
>
> mcspi->dma_channels[i].dma_tx_channel = -1;
> @@ -1176,23 +1178,24 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev)
>
> pm_runtime_enable(&pdev->dev);
>
> - if (status || omap2_mcspi_master_setup(mcspi) < 0)
> - goto err3;
> + status = omap2_mcspi_master_setup(mcspi);
> + if (status)
> + goto err_free_dma_channels;
>
> status = spi_register_master(master);
> if (status < 0)
> - goto err4;
> + goto err_free_dma_channels;
>
> - return status;
> + return 0;
>
> -err4:
> - spi_master_put(master);
> -err3:
> +err_free_dma_channels:
> kfree(mcspi->dma_channels);
> -err2:
> - release_mem_region(r->start, resource_size(r));
> +err_iounmap:
> iounmap(mcspi->base);
> -err1:
> +err_release_mem_region:
> + release_mem_region(r->start, resource_size(r));
> +err_put_master:
> + spi_master_put(master);
> return status;
> }
>
> --
> 1.7.4.1
>
>
>
>
--
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] spi: omap2-mcspi: fix omap2_mcspi_probe error handling
@ 2011-06-27 4:23 ` Axel Lin
0 siblings, 0 replies; 4+ messages in thread
From: Axel Lin @ 2011-06-27 4:23 UTC (permalink / raw)
To: Grant Likely; +Cc: linux-kernel, Samuel Ortiz, Juha Yrjola, spi-devel-general
2011/6/22 Grant Likely <grant.likely@secretlab.ca>:
> On Wed, Jun 22, 2011 at 7:57 AM, Axel Lin <axel.lin@gmail.com> wrote:
>> This patch includes below fixes for error handling:
>> 1. return proper error if kcalloc for mcspi->dma_channels fails
>> 2. return proper error if omap2_mcspi_master_setup fails
>> 3. properly release allocated resources in error paths and
>> improve the naming of goto labels.
>
> Is this to be applied immediately, or queued up in linux-next for v3.1?
>
It's not urgent. It's ok to queue up in linux-next for v3.1.
Axel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] spi: omap2-mcspi: fix omap2_mcspi_probe error handling
@ 2011-06-27 4:23 ` Axel Lin
0 siblings, 0 replies; 4+ messages in thread
From: Axel Lin @ 2011-06-27 4:23 UTC (permalink / raw)
To: Grant Likely
Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, Juha Yrjola,
linux-kernel-u79uwXL29TY76Z2rM5mHXA, Samuel Ortiz
2011/6/22 Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>:
> On Wed, Jun 22, 2011 at 7:57 AM, Axel Lin <axel.lin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>> This patch includes below fixes for error handling:
>> 1. return proper error if kcalloc for mcspi->dma_channels fails
>> 2. return proper error if omap2_mcspi_master_setup fails
>> 3. properly release allocated resources in error paths and
>> improve the naming of goto labels.
>
> Is this to be applied immediately, or queued up in linux-next for v3.1?
>
It's not urgent. It's ok to queue up in linux-next for v3.1.
Axel
------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-06-27 4:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-22 13:57 [PATCH] spi: omap2-mcspi: fix omap2_mcspi_probe error handling Axel Lin
2011-06-22 15:29 ` Grant Likely
2011-06-27 4:23 ` Axel Lin
2011-06-27 4:23 ` Axel Lin
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.