* [PATCH v2] ARM: pxa: ssp: remove unnessary free for devm_xxx
@ 2015-06-08 8:06 Firo Yang
2015-06-08 8:09 ` Julia Lawall
0 siblings, 1 reply; 7+ messages in thread
From: Firo Yang @ 2015-06-08 8:06 UTC (permalink / raw)
To: linux-arm-kernel
A Coccinelle warning.
It's not necessary to free memory allocated with devm_xxx
and using these free functions maybe lead to a double free that
will corrupt the resource subsys. So, I just remove them.
By the way, I replace devm_request_mem_region and devm_ioremap with
devm_ioremap_resource as Julia's suggestion.
Signed-off-by: Firo Yang <firogm@gmail.com>
---
arch/arm/plat-pxa/ssp.c | 24 +++---------------------
1 file changed, 3 insertions(+), 21 deletions(-)
diff --git a/arch/arm/plat-pxa/ssp.c b/arch/arm/plat-pxa/ssp.c
index ad9529c..a278ea0 100644
--- a/arch/arm/plat-pxa/ssp.c
+++ b/arch/arm/plat-pxa/ssp.c
@@ -182,21 +182,12 @@ static int pxa_ssp_probe(struct platform_device *pdev)
return -ENODEV;
}
- res = devm_request_mem_region(dev, res->start, resource_size(res),
- pdev->name);
- if (res == NULL) {
- dev_err(dev, "failed to request memory resource\n");
- return -EBUSY;
- }
+ ssp->mmio_base = devm_ioremap_resource(dev, res);
+ if (IS_ERR(ssp->mmio_base))
+ return PTR_ERR(ssp->mmio_base);
ssp->phys_base = res->start;
- ssp->mmio_base = devm_ioremap(dev, res->start, resource_size(res));
- if (ssp->mmio_base == NULL) {
- dev_err(dev, "failed to ioremap() registers\n");
- return -ENODEV;
- }
-
ssp->irq = platform_get_irq(pdev, 0);
if (ssp->irq < 0) {
dev_err(dev, "no IRQ resource defined\n");
@@ -232,25 +223,16 @@ static int pxa_ssp_probe(struct platform_device *pdev)
static int pxa_ssp_remove(struct platform_device *pdev)
{
- struct resource *res;
struct ssp_device *ssp;
ssp = platform_get_drvdata(pdev);
if (ssp == NULL)
return -ENODEV;
- iounmap(ssp->mmio_base);
-
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- release_mem_region(res->start, resource_size(res));
-
- clk_put(ssp->clk);
-
mutex_lock(&ssp_lock);
list_del(&ssp->node);
mutex_unlock(&ssp_lock);
- kfree(ssp);
return 0;
}
--
2.4.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2] ARM: pxa: ssp: remove unnessary free for devm_xxx
2015-06-08 8:06 [PATCH v2] ARM: pxa: ssp: remove unnessary free for devm_xxx Firo Yang
@ 2015-06-08 8:09 ` Julia Lawall
2015-06-08 8:19 ` Firo Yang
0 siblings, 1 reply; 7+ messages in thread
From: Julia Lawall @ 2015-06-08 8:09 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, 8 Jun 2015, Firo Yang wrote:
> A Coccinelle warning.
> It's not necessary to free memory allocated with devm_xxx
> and using these free functions maybe lead to a double free that
> will corrupt the resource subsys. So, I just remove them.
>
> By the way, I replace devm_request_mem_region and devm_ioremap with
> devm_ioremap_resource as Julia's suggestion.
I think they should be done separately. The first patch fixes a bug. The
second one just simplifies/modernizes the code.
julia
>
> Signed-off-by: Firo Yang <firogm@gmail.com>
> ---
> arch/arm/plat-pxa/ssp.c | 24 +++---------------------
> 1 file changed, 3 insertions(+), 21 deletions(-)
>
> diff --git a/arch/arm/plat-pxa/ssp.c b/arch/arm/plat-pxa/ssp.c
> index ad9529c..a278ea0 100644
> --- a/arch/arm/plat-pxa/ssp.c
> +++ b/arch/arm/plat-pxa/ssp.c
> @@ -182,21 +182,12 @@ static int pxa_ssp_probe(struct platform_device *pdev)
> return -ENODEV;
> }
>
> - res = devm_request_mem_region(dev, res->start, resource_size(res),
> - pdev->name);
> - if (res == NULL) {
> - dev_err(dev, "failed to request memory resource\n");
> - return -EBUSY;
> - }
> + ssp->mmio_base = devm_ioremap_resource(dev, res);
> + if (IS_ERR(ssp->mmio_base))
> + return PTR_ERR(ssp->mmio_base);
>
> ssp->phys_base = res->start;
>
> - ssp->mmio_base = devm_ioremap(dev, res->start, resource_size(res));
> - if (ssp->mmio_base == NULL) {
> - dev_err(dev, "failed to ioremap() registers\n");
> - return -ENODEV;
> - }
> -
> ssp->irq = platform_get_irq(pdev, 0);
> if (ssp->irq < 0) {
> dev_err(dev, "no IRQ resource defined\n");
> @@ -232,25 +223,16 @@ static int pxa_ssp_probe(struct platform_device *pdev)
>
> static int pxa_ssp_remove(struct platform_device *pdev)
> {
> - struct resource *res;
> struct ssp_device *ssp;
>
> ssp = platform_get_drvdata(pdev);
> if (ssp == NULL)
> return -ENODEV;
>
> - iounmap(ssp->mmio_base);
> -
> - res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> - release_mem_region(res->start, resource_size(res));
> -
> - clk_put(ssp->clk);
> -
> mutex_lock(&ssp_lock);
> list_del(&ssp->node);
> mutex_unlock(&ssp_lock);
>
> - kfree(ssp);
> return 0;
> }
>
> --
> 2.4.2
>
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2] ARM: pxa: ssp: remove unnessary free for devm_xxx
2015-06-08 8:09 ` Julia Lawall
@ 2015-06-08 8:19 ` Firo Yang
2015-06-08 8:21 ` Julia Lawall
0 siblings, 1 reply; 7+ messages in thread
From: Firo Yang @ 2015-06-08 8:19 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, Jun 08, 2015 at 10:09:31AM +0200, Julia Lawall wrote:
>On Mon, 8 Jun 2015, Firo Yang wrote:
>
>> A Coccinelle warning.
>> It's not necessary to free memory allocated with devm_xxx
>> and using these free functions maybe lead to a double free that
>> will corrupt the resource subsys. So, I just remove them.
>>
>> By the way, I replace devm_request_mem_region and devm_ioremap with
>> devm_ioremap_resource as Julia's suggestion.
>
>I think they should be done separately. The first patch fixes a bug. The
>second one just simplifies/modernizes the code.
Ok, I will send another patch with simplified code separately.
But, what about this patch? Will it be discared?
>
>julia
>
>>
>> Signed-off-by: Firo Yang <firogm@gmail.com>
>> ---
>> arch/arm/plat-pxa/ssp.c | 24 +++---------------------
>> 1 file changed, 3 insertions(+), 21 deletions(-)
>>
>> diff --git a/arch/arm/plat-pxa/ssp.c b/arch/arm/plat-pxa/ssp.c
>> index ad9529c..a278ea0 100644
>> --- a/arch/arm/plat-pxa/ssp.c
>> +++ b/arch/arm/plat-pxa/ssp.c
>> @@ -182,21 +182,12 @@ static int pxa_ssp_probe(struct platform_device *pdev)
>> return -ENODEV;
>> }
>>
>> - res = devm_request_mem_region(dev, res->start, resource_size(res),
>> - pdev->name);
>> - if (res == NULL) {
>> - dev_err(dev, "failed to request memory resource\n");
>> - return -EBUSY;
>> - }
>> + ssp->mmio_base = devm_ioremap_resource(dev, res);
>> + if (IS_ERR(ssp->mmio_base))
>> + return PTR_ERR(ssp->mmio_base);
>>
>> ssp->phys_base = res->start;
>>
>> - ssp->mmio_base = devm_ioremap(dev, res->start, resource_size(res));
>> - if (ssp->mmio_base == NULL) {
>> - dev_err(dev, "failed to ioremap() registers\n");
>> - return -ENODEV;
>> - }
>> -
>> ssp->irq = platform_get_irq(pdev, 0);
>> if (ssp->irq < 0) {
>> dev_err(dev, "no IRQ resource defined\n");
>> @@ -232,25 +223,16 @@ static int pxa_ssp_probe(struct platform_device *pdev)
>>
>> static int pxa_ssp_remove(struct platform_device *pdev)
>> {
>> - struct resource *res;
>> struct ssp_device *ssp;
>>
>> ssp = platform_get_drvdata(pdev);
>> if (ssp == NULL)
>> return -ENODEV;
>>
>> - iounmap(ssp->mmio_base);
>> -
>> - res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>> - release_mem_region(res->start, resource_size(res));
>> -
>> - clk_put(ssp->clk);
>> -
>> mutex_lock(&ssp_lock);
>> list_del(&ssp->node);
>> mutex_unlock(&ssp_lock);
>>
>> - kfree(ssp);
>> return 0;
>> }
>>
>> --
>> 2.4.2
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
>> the body of a message to majordomo at vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>>
--
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2] ARM: pxa: ssp: remove unnessary free for devm_xxx
2015-06-08 8:19 ` Firo Yang
@ 2015-06-08 8:21 ` Julia Lawall
2015-06-08 8:23 ` Firo Yang
0 siblings, 1 reply; 7+ messages in thread
From: Julia Lawall @ 2015-06-08 8:21 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, 8 Jun 2015, Firo Yang wrote:
> On Mon, Jun 08, 2015 at 10:09:31AM +0200, Julia Lawall wrote:
> >On Mon, 8 Jun 2015, Firo Yang wrote:
> >
> >> A Coccinelle warning.
> >> It's not necessary to free memory allocated with devm_xxx
> >> and using these free functions maybe lead to a double free that
> >> will corrupt the resource subsys. So, I just remove them.
> >>
> >> By the way, I replace devm_request_mem_region and devm_ioremap with
> >> devm_ioremap_resource as Julia's suggestion.
> >
> >I think they should be done separately. The first patch fixes a bug. The
> >second one just simplifies/modernizes the code.
>
> Ok, I will send another patch with simplified code separately.
> But, what about this patch? Will it be discared?
Maybe you can put a comment under the --- explaining the situation.
julia
>
> >
> >julia
> >
> >>
> >> Signed-off-by: Firo Yang <firogm@gmail.com>
> >> ---
> >> arch/arm/plat-pxa/ssp.c | 24 +++---------------------
> >> 1 file changed, 3 insertions(+), 21 deletions(-)
> >>
> >> diff --git a/arch/arm/plat-pxa/ssp.c b/arch/arm/plat-pxa/ssp.c
> >> index ad9529c..a278ea0 100644
> >> --- a/arch/arm/plat-pxa/ssp.c
> >> +++ b/arch/arm/plat-pxa/ssp.c
> >> @@ -182,21 +182,12 @@ static int pxa_ssp_probe(struct platform_device *pdev)
> >> return -ENODEV;
> >> }
> >>
> >> - res = devm_request_mem_region(dev, res->start, resource_size(res),
> >> - pdev->name);
> >> - if (res == NULL) {
> >> - dev_err(dev, "failed to request memory resource\n");
> >> - return -EBUSY;
> >> - }
> >> + ssp->mmio_base = devm_ioremap_resource(dev, res);
> >> + if (IS_ERR(ssp->mmio_base))
> >> + return PTR_ERR(ssp->mmio_base);
> >>
> >> ssp->phys_base = res->start;
> >>
> >> - ssp->mmio_base = devm_ioremap(dev, res->start, resource_size(res));
> >> - if (ssp->mmio_base == NULL) {
> >> - dev_err(dev, "failed to ioremap() registers\n");
> >> - return -ENODEV;
> >> - }
> >> -
> >> ssp->irq = platform_get_irq(pdev, 0);
> >> if (ssp->irq < 0) {
> >> dev_err(dev, "no IRQ resource defined\n");
> >> @@ -232,25 +223,16 @@ static int pxa_ssp_probe(struct platform_device *pdev)
> >>
> >> static int pxa_ssp_remove(struct platform_device *pdev)
> >> {
> >> - struct resource *res;
> >> struct ssp_device *ssp;
> >>
> >> ssp = platform_get_drvdata(pdev);
> >> if (ssp == NULL)
> >> return -ENODEV;
> >>
> >> - iounmap(ssp->mmio_base);
> >> -
> >> - res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> >> - release_mem_region(res->start, resource_size(res));
> >> -
> >> - clk_put(ssp->clk);
> >> -
> >> mutex_lock(&ssp_lock);
> >> list_del(&ssp->node);
> >> mutex_unlock(&ssp_lock);
> >>
> >> - kfree(ssp);
> >> return 0;
> >> }
> >>
> >> --
> >> 2.4.2
> >>
> >> --
> >> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> >> the body of a message to majordomo at vger.kernel.org
> >> More majordomo info at http://vger.kernel.org/majordomo-info.html
> >>
>
> --
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2] ARM: pxa: ssp: remove unnessary free for devm_xxx
2015-06-08 8:21 ` Julia Lawall
@ 2015-06-08 8:23 ` Firo Yang
2015-06-08 8:33 ` Julia Lawall
0 siblings, 1 reply; 7+ messages in thread
From: Firo Yang @ 2015-06-08 8:23 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, Jun 08, 2015 at 10:21:41AM +0200, Julia Lawall wrote:
>On Mon, 8 Jun 2015, Firo Yang wrote:
>
>> On Mon, Jun 08, 2015 at 10:09:31AM +0200, Julia Lawall wrote:
>> >On Mon, 8 Jun 2015, Firo Yang wrote:
>> >
>> >> A Coccinelle warning.
>> >> It's not necessary to free memory allocated with devm_xxx
>> >> and using these free functions maybe lead to a double free that
>> >> will corrupt the resource subsys. So, I just remove them.
>> >>
>> >> By the way, I replace devm_request_mem_region and devm_ioremap with
>> >> devm_ioremap_resource as Julia's suggestion.
>> >
>> >I think they should be done separately. The first patch fixes a bug. The
>> >second one just simplifies/modernizes the code.
>>
>> Ok, I will send another patch with simplified code separately.
>> But, what about this patch? Will it be discared?
>
>Maybe you can put a comment under the --- explaining the situation.
Sorry, --- stands for what?
>
>julia
>
>>
>> >
>> >julia
>> >
>> >>
>> >> Signed-off-by: Firo Yang <firogm@gmail.com>
>> >> ---
>> >> arch/arm/plat-pxa/ssp.c | 24 +++---------------------
>> >> 1 file changed, 3 insertions(+), 21 deletions(-)
>> >>
>> >> diff --git a/arch/arm/plat-pxa/ssp.c b/arch/arm/plat-pxa/ssp.c
>> >> index ad9529c..a278ea0 100644
>> >> --- a/arch/arm/plat-pxa/ssp.c
>> >> +++ b/arch/arm/plat-pxa/ssp.c
>> >> @@ -182,21 +182,12 @@ static int pxa_ssp_probe(struct platform_device *pdev)
>> >> return -ENODEV;
>> >> }
>> >>
>> >> - res = devm_request_mem_region(dev, res->start, resource_size(res),
>> >> - pdev->name);
>> >> - if (res == NULL) {
>> >> - dev_err(dev, "failed to request memory resource\n");
>> >> - return -EBUSY;
>> >> - }
>> >> + ssp->mmio_base = devm_ioremap_resource(dev, res);
>> >> + if (IS_ERR(ssp->mmio_base))
>> >> + return PTR_ERR(ssp->mmio_base);
>> >>
>> >> ssp->phys_base = res->start;
>> >>
>> >> - ssp->mmio_base = devm_ioremap(dev, res->start, resource_size(res));
>> >> - if (ssp->mmio_base == NULL) {
>> >> - dev_err(dev, "failed to ioremap() registers\n");
>> >> - return -ENODEV;
>> >> - }
>> >> -
>> >> ssp->irq = platform_get_irq(pdev, 0);
>> >> if (ssp->irq < 0) {
>> >> dev_err(dev, "no IRQ resource defined\n");
>> >> @@ -232,25 +223,16 @@ static int pxa_ssp_probe(struct platform_device *pdev)
>> >>
>> >> static int pxa_ssp_remove(struct platform_device *pdev)
>> >> {
>> >> - struct resource *res;
>> >> struct ssp_device *ssp;
>> >>
>> >> ssp = platform_get_drvdata(pdev);
>> >> if (ssp == NULL)
>> >> return -ENODEV;
>> >>
>> >> - iounmap(ssp->mmio_base);
>> >> -
>> >> - res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>> >> - release_mem_region(res->start, resource_size(res));
>> >> -
>> >> - clk_put(ssp->clk);
>> >> -
>> >> mutex_lock(&ssp_lock);
>> >> list_del(&ssp->node);
>> >> mutex_unlock(&ssp_lock);
>> >>
>> >> - kfree(ssp);
>> >> return 0;
>> >> }
>> >>
>> >> --
>> >> 2.4.2
>> >>
>> >> --
>> >> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
>> >> the body of a message to majordomo at vger.kernel.org
>> >> More majordomo info at http://vger.kernel.org/majordomo-info.html
>> >>
>>
>> --
>> --
>> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
>> the body of a message to majordomo at vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>>
--
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2] ARM: pxa: ssp: remove unnessary free for devm_xxx
2015-06-08 8:23 ` Firo Yang
@ 2015-06-08 8:33 ` Julia Lawall
2015-06-08 8:39 ` Firo Yang
0 siblings, 1 reply; 7+ messages in thread
From: Julia Lawall @ 2015-06-08 8:33 UTC (permalink / raw)
To: linux-arm-kernel
> >Maybe you can put a comment under the --- explaining the situation.
>
> Sorry, --- stands for what?
In your patch you have a --- after the commit message and before the diff.
If you put some text under the --- and before the diff, the person who
reads the mail will see it, but it will not go into the git log.
julia
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2] ARM: pxa: ssp: remove unnessary free for devm_xxx
2015-06-08 8:33 ` Julia Lawall
@ 2015-06-08 8:39 ` Firo Yang
0 siblings, 0 replies; 7+ messages in thread
From: Firo Yang @ 2015-06-08 8:39 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, Jun 08, 2015 at 10:33:09AM +0200, Julia Lawall wrote:
>> >Maybe you can put a comment under the --- explaining the situation.
>>
>> Sorry, --- stands for what?
>
>In your patch you have a --- after the commit message and before the diff.
>If you put some text under the --- and before the diff, the person who
>reads the mail will see it, but it will not go into the git log.
Oh, many thanks!
Firo
>
>julia
--
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2015-06-08 8:39 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-08 8:06 [PATCH v2] ARM: pxa: ssp: remove unnessary free for devm_xxx Firo Yang
2015-06-08 8:09 ` Julia Lawall
2015-06-08 8:19 ` Firo Yang
2015-06-08 8:21 ` Julia Lawall
2015-06-08 8:23 ` Firo Yang
2015-06-08 8:33 ` Julia Lawall
2015-06-08 8:39 ` Firo Yang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).