* [PATCH] spi: omap2-mcspi: Fix the error handling in probe
@ 2012-08-01 9:36 ` Shubhrajyoti D
0 siblings, 0 replies; 10+ messages in thread
From: Shubhrajyoti D @ 2012-08-01 9:36 UTC (permalink / raw)
To: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
Cc: broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E,
linux-kernel-u79uwXL29TY76Z2rM5mHXA, Guenter Roeck,
Shubhrajyoti D
The kfree() is taken care of by the spi core (spi_master_release() function)
that is called once the last reference to the underlying struct device has
been released. So the driver need not call kfree.
Also the put was missed in some of the error handling fix the same.
There by fixing the missing device_put in some of the error paths.
Cc: Guenter Roeck <linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
Signed-off-by: Shubhrajyoti D <shubhrajyoti-l0cyMroinI0@public.gmane.org>
---
drivers/spi/spi-omap2-mcspi.c | 6 ++----
1 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 7d46b15..b5035e2 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -1203,18 +1203,16 @@ static int __devinit omap2_mcspi_probe(struct platform_device *pdev)
status = spi_register_master(master);
if (status < 0)
- goto err_spi_register;
+ goto disable_pm;
return status;
-err_spi_register:
- spi_master_put(master);
disable_pm:
pm_runtime_disable(&pdev->dev);
dma_chnl_free:
kfree(mcspi->dma_channels);
free_master:
- kfree(master);
+ spi_master_put(master);
platform_set_drvdata(pdev, NULL);
return status;
}
--
1.7.5.4
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH] spi: omap2-mcspi: Fix the error handling in probe
@ 2012-08-01 9:36 ` Shubhrajyoti D
0 siblings, 0 replies; 10+ messages in thread
From: Shubhrajyoti D @ 2012-08-01 9:36 UTC (permalink / raw)
To: spi-devel-general; +Cc: broonie, linux-kernel, Shubhrajyoti D, Guenter Roeck
The kfree() is taken care of by the spi core (spi_master_release() function)
that is called once the last reference to the underlying struct device has
been released. So the driver need not call kfree.
Also the put was missed in some of the error handling fix the same.
There by fixing the missing device_put in some of the error paths.
Cc: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com>
---
drivers/spi/spi-omap2-mcspi.c | 6 ++----
1 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 7d46b15..b5035e2 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -1203,18 +1203,16 @@ static int __devinit omap2_mcspi_probe(struct platform_device *pdev)
status = spi_register_master(master);
if (status < 0)
- goto err_spi_register;
+ goto disable_pm;
return status;
-err_spi_register:
- spi_master_put(master);
disable_pm:
pm_runtime_disable(&pdev->dev);
dma_chnl_free:
kfree(mcspi->dma_channels);
free_master:
- kfree(master);
+ spi_master_put(master);
platform_set_drvdata(pdev, NULL);
return status;
}
--
1.7.5.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] spi: omap2-mcspi: Fix the error handling in probe
2012-08-01 9:36 ` Shubhrajyoti D
(?)
@ 2012-08-01 15:07 ` Guenter Roeck
2012-08-02 10:07 ` Shubhrajyoti
-1 siblings, 1 reply; 10+ messages in thread
From: Guenter Roeck @ 2012-08-01 15:07 UTC (permalink / raw)
To: Shubhrajyoti D; +Cc: spi-devel-general, broonie, linux-kernel
On Wed, Aug 01, 2012 at 03:06:28PM +0530, Shubhrajyoti D wrote:
> The kfree() is taken care of by the spi core (spi_master_release() function)
> that is called once the last reference to the underlying struct device has
> been released. So the driver need not call kfree.
>
> Also the put was missed in some of the error handling fix the same.
> There by fixing the missing device_put in some of the error paths.
>
> Cc: Guenter Roeck <linux@roeck-us.net>
Reported-by: may be better here.
> Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com>
Acked-by: Guenter Roeck <linux@roeck-us.net>
I suspect that "spi_master_put(master);" may also be missing in
omap2_mcspi_remove(), but we'll need someone to confirm that.
Thanks,
Guenter
> ---
> drivers/spi/spi-omap2-mcspi.c | 6 ++----
> 1 files changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
> index 7d46b15..b5035e2 100644
> --- a/drivers/spi/spi-omap2-mcspi.c
> +++ b/drivers/spi/spi-omap2-mcspi.c
> @@ -1203,18 +1203,16 @@ static int __devinit omap2_mcspi_probe(struct platform_device *pdev)
>
> status = spi_register_master(master);
> if (status < 0)
> - goto err_spi_register;
> + goto disable_pm;
>
> return status;
>
> -err_spi_register:
> - spi_master_put(master);
> disable_pm:
> pm_runtime_disable(&pdev->dev);
> dma_chnl_free:
> kfree(mcspi->dma_channels);
> free_master:
> - kfree(master);
> + spi_master_put(master);
> platform_set_drvdata(pdev, NULL);
> return status;
> }
> --
> 1.7.5.4
>
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] spi: omap2-mcspi: Fix the error handling in probe
2012-08-01 15:07 ` Guenter Roeck
@ 2012-08-02 10:07 ` Shubhrajyoti
2012-08-02 14:57 ` Guenter Roeck
0 siblings, 1 reply; 10+ messages in thread
From: Shubhrajyoti @ 2012-08-02 10:07 UTC (permalink / raw)
To: Guenter Roeck; +Cc: spi-devel-general, broonie, linux-kernel
On Wednesday 01 August 2012 08:37 PM, Guenter Roeck wrote:
> On Wed, Aug 01, 2012 at 03:06:28PM +0530, Shubhrajyoti D wrote:
>> The kfree() is taken care of by the spi core (spi_master_release() function)
>> that is called once the last reference to the underlying struct device has
>> been released. So the driver need not call kfree.
>>
>> Also the put was missed in some of the error handling fix the same.
>> There by fixing the missing device_put in some of the error paths.
>>
>> Cc: Guenter Roeck <linux@roeck-us.net>
> Reported-by: may be better here.
My bad. I should have done.
>
>> Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com>
> Acked-by: Guenter Roeck <linux@roeck-us.net>
thanks.
> I suspect that "spi_master_put(master);" may also be missing in
> omap2_mcspi_remove(), but we'll need someone to confirm that.
Looks unlikely.
spi_master_put does a
...
if (master)
put_device(&master->dev);
...
In remove I call
spi_unregister_master
...
*/
void spi_unregister_master(struct spi_master *master)
{
int dummy;
[...]
dummy = device_for_each_child(&master->dev, NULL, __unregister);
device_unregister(&master->dev);
}
and
void device_unregister(struct device *dev)
{
[..]
device_del(dev);
put_device(dev);
}
Hope my understanding is correct.
> Thanks,
> Guenter
>
>> ---
>> drivers/spi/spi-omap2-mcspi.c | 6 ++----
>> 1 files changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
>> index 7d46b15..b5035e2 100644
>> --- a/drivers/spi/spi-omap2-mcspi.c
>> +++ b/drivers/spi/spi-omap2-mcspi.c
>> @@ -1203,18 +1203,16 @@ static int __devinit omap2_mcspi_probe(struct platform_device *pdev)
>>
>> status = spi_register_master(master);
>> if (status < 0)
>> - goto err_spi_register;
>> + goto disable_pm;
>>
>> return status;
>>
>> -err_spi_register:
>> - spi_master_put(master);
>> disable_pm:
>> pm_runtime_disable(&pdev->dev);
>> dma_chnl_free:
>> kfree(mcspi->dma_channels);
>> free_master:
>> - kfree(master);
>> + spi_master_put(master);
>> platform_set_drvdata(pdev, NULL);
>> return status;
>> }
>> --
>> 1.7.5.4
>>
>>
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH] spi: omap2-mcspi: Fix the error handling in probe
2012-08-02 10:07 ` Shubhrajyoti
@ 2012-08-02 14:57 ` Guenter Roeck
0 siblings, 0 replies; 10+ messages in thread
From: Guenter Roeck @ 2012-08-02 14:57 UTC (permalink / raw)
To: Shubhrajyoti; +Cc: spi-devel-general, broonie, linux-kernel
On Thu, Aug 02, 2012 at 03:37:13PM +0530, Shubhrajyoti wrote:
> On Wednesday 01 August 2012 08:37 PM, Guenter Roeck wrote:
> > On Wed, Aug 01, 2012 at 03:06:28PM +0530, Shubhrajyoti D wrote:
> >> The kfree() is taken care of by the spi core (spi_master_release() function)
> >> that is called once the last reference to the underlying struct device has
> >> been released. So the driver need not call kfree.
> >>
> >> Also the put was missed in some of the error handling fix the same.
> >> There by fixing the missing device_put in some of the error paths.
> >>
> >> Cc: Guenter Roeck <linux@roeck-us.net>
> > Reported-by: may be better here.
> My bad. I should have done.
> >
> >> Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com>
> > Acked-by: Guenter Roeck <linux@roeck-us.net>
> thanks.
> > I suspect that "spi_master_put(master);" may also be missing in
> > omap2_mcspi_remove(), but we'll need someone to confirm that.
> Looks unlikely.
>
> spi_master_put does a
> ...
> if (master)
> put_device(&master->dev);
> ...
>
> In remove I call
>
> spi_unregister_master
> ...
> */
> void spi_unregister_master(struct spi_master *master)
> {
> int dummy;
> [...]
>
> dummy = device_for_each_child(&master->dev, NULL, __unregister);
> device_unregister(&master->dev);
> }
>
> and
>
> void device_unregister(struct device *dev)
> {
> [..]
> device_del(dev);
> put_device(dev);
> }
>
> Hope my understanding is correct.
>
I think it is; I checked the refcount. spi_register_master increases
refcount from 1 to 3, and spi_unregister_master decreases it from 3 to 0.
Now, if _my_ understanding is correct, that means the data structure allocated
with spi_alloc_master, and specifically the device private data structure
(struct omap2_mcspi in your case), is freed with spi_unregister_master().
If so, it must not be accessed after the call to spi_unregister_master().
However, many drivers do access this data after the call to
spi_unregister_master(). spi-tegra.c is a good example, but there are many
others. Does that mean that those drivers access freed memory ?
Also, some other drivers do call spi_master_put() after spi_unregister_master(),
with no matching spi_master_get() (eg spi-topcliff-pch.c). Does that mean that
those drivers call spi_master_put() on free memory ?
Thanks,
Guenter
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH] spi: omap2-mcspi: Fix the error handling in probe
@ 2012-08-02 11:11 ` Shubhrajyoti D
0 siblings, 0 replies; 10+ messages in thread
From: Shubhrajyoti D @ 2012-08-02 11:11 UTC (permalink / raw)
To: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
Cc: linux-omap-u79uwXL29TY76Z2rM5mHXA,
broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E,
linux-kernel-u79uwXL29TY76Z2rM5mHXA, Shubhrajyoti D
The kfree() is taken care of by the spi core (spi_master_release() function)
that is called once the last reference to the underlying struct device has
been released. So the driver need not call kfree.
Also the put was missed in some of the error handling fix the same.
There by fixing the missing device_put in some of the error paths.
Acked-by: Guenter Roeck <linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
Reported-by: Guenter Roeck <linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
Signed-off-by: Shubhrajyoti D <shubhrajyoti-l0cyMroinI0@public.gmane.org>
---
drivers/spi/spi-omap2-mcspi.c | 6 ++----
1 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index bc47781..b2fb141 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -1228,18 +1228,16 @@ static int __devinit omap2_mcspi_probe(struct platform_device *pdev)
status = spi_register_master(master);
if (status < 0)
- goto err_spi_register;
+ goto disable_pm;
return status;
-err_spi_register:
- spi_master_put(master);
disable_pm:
pm_runtime_disable(&pdev->dev);
dma_chnl_free:
kfree(mcspi->dma_channels);
free_master:
- kfree(master);
+ spi_master_put(master);
platform_set_drvdata(pdev, NULL);
return status;
}
--
1.7.5.4
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH] spi: omap2-mcspi: Fix the error handling in probe
@ 2012-08-02 11:11 ` Shubhrajyoti D
0 siblings, 0 replies; 10+ messages in thread
From: Shubhrajyoti D @ 2012-08-02 11:11 UTC (permalink / raw)
To: spi-devel-general
Cc: broonie, grant.likely, linux-omap, linux-kernel, Shubhrajyoti D
The kfree() is taken care of by the spi core (spi_master_release() function)
that is called once the last reference to the underlying struct device has
been released. So the driver need not call kfree.
Also the put was missed in some of the error handling fix the same.
There by fixing the missing device_put in some of the error paths.
Acked-by: Guenter Roeck <linux@roeck-us.net>
Reported-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com>
---
drivers/spi/spi-omap2-mcspi.c | 6 ++----
1 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index bc47781..b2fb141 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -1228,18 +1228,16 @@ static int __devinit omap2_mcspi_probe(struct platform_device *pdev)
status = spi_register_master(master);
if (status < 0)
- goto err_spi_register;
+ goto disable_pm;
return status;
-err_spi_register:
- spi_master_put(master);
disable_pm:
pm_runtime_disable(&pdev->dev);
dma_chnl_free:
kfree(mcspi->dma_channels);
free_master:
- kfree(master);
+ spi_master_put(master);
platform_set_drvdata(pdev, NULL);
return status;
}
--
1.7.5.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH] spi: omap2-mcspi: Fix the error handling in probe
@ 2012-08-02 11:11 ` Shubhrajyoti D
0 siblings, 0 replies; 10+ messages in thread
From: Shubhrajyoti D @ 2012-08-02 11:11 UTC (permalink / raw)
To: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
Cc: linux-omap-u79uwXL29TY76Z2rM5mHXA,
broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E,
linux-kernel-u79uwXL29TY76Z2rM5mHXA, Shubhrajyoti D
The kfree() is taken care of by the spi core (spi_master_release() function)
that is called once the last reference to the underlying struct device has
been released. So the driver need not call kfree.
Also the put was missed in some of the error handling fix the same.
There by fixing the missing device_put in some of the error paths.
Acked-by: Guenter Roeck <linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
Reported-by: Guenter Roeck <linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
Signed-off-by: Shubhrajyoti D <shubhrajyoti-l0cyMroinI0@public.gmane.org>
---
drivers/spi/spi-omap2-mcspi.c | 6 ++----
1 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index bc47781..b2fb141 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -1228,18 +1228,16 @@ static int __devinit omap2_mcspi_probe(struct platform_device *pdev)
status = spi_register_master(master);
if (status < 0)
- goto err_spi_register;
+ goto disable_pm;
return status;
-err_spi_register:
- spi_master_put(master);
disable_pm:
pm_runtime_disable(&pdev->dev);
dma_chnl_free:
kfree(mcspi->dma_channels);
free_master:
- kfree(master);
+ spi_master_put(master);
platform_set_drvdata(pdev, NULL);
return status;
}
--
1.7.5.4
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
^ permalink raw reply related [flat|nested] 10+ messages in thread
[parent not found: <1343905885-31549-1-git-send-email-shubhrajyoti-l0cyMroinI0@public.gmane.org>]
* Re: [PATCH] spi: omap2-mcspi: Fix the error handling in probe
2012-08-02 11:11 ` Shubhrajyoti D
@ 2012-08-04 11:06 ` Mark Brown
-1 siblings, 0 replies; 10+ messages in thread
From: Mark Brown @ 2012-08-04 11:06 UTC (permalink / raw)
To: Shubhrajyoti D
Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
linux-omap-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
On Thu, Aug 02, 2012 at 04:41:25PM +0530, Shubhrajyoti D wrote:
> The kfree() is taken care of by the spi core (spi_master_release() function)
> that is called once the last reference to the underlying struct device has
> been released. So the driver need not call kfree.
Applied, thanks.
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2012-08-04 13:05 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-01 9:36 [PATCH] spi: omap2-mcspi: Fix the error handling in probe Shubhrajyoti D
2012-08-01 9:36 ` Shubhrajyoti D
2012-08-01 15:07 ` Guenter Roeck
2012-08-02 10:07 ` Shubhrajyoti
2012-08-02 14:57 ` Guenter Roeck
-- strict thread matches above, loose matches on Subject: below --
2012-08-02 11:11 Shubhrajyoti D
2012-08-02 11:11 ` Shubhrajyoti D
2012-08-02 11:11 ` Shubhrajyoti D
[not found] ` <1343905885-31549-1-git-send-email-shubhrajyoti-l0cyMroinI0@public.gmane.org>
2012-08-04 11:06 ` Mark Brown
2012-08-04 11:06 ` Mark Brown
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.