ARM: pxa: ssp: remove unnessary free for devm_xxx
Subsystems (3)
PATCH v2 1/1 ARM: pxa: ssp: remove unnessary free for devm_xxx
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.
--- arch/arm/plat-pxa/ssp.c | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-)
arch/arm/plat-pxa/ssp.c +3 -21
@@ -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 ; }
Signature · 1 line
2.4.2
Quoted 7 lines · Firo Yang
A Coccinelle warning.
It's not necessary to free memory allocated withdevm_xxxand 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_regionanddevm_ioremapwithdevm_ioremap_resourceas 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
Quoted 69 lines
Signed-off-by Firo Yang <[email protected]>--- arch/arm/plat-pxa/ssp.c | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-)arch/arm/plat-pxa/ssp.c +3
-22@@ -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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 7 lines · Julia Lawall
Quoted 5 lines · Firo Yang
A Coccinelle warning.
It's not necessary to free memory allocated withdevm_xxxand using these free functions maybe lead to a double free that will corrupt the resource subsys. So, I just remove them.
Quoted 5 lines
Quoted 2 lines
By the way, I replace
devm_request_mem_regionanddevm_ioremapwithdevm_ioremap_resourceas 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?
Quoted 72 lines
julia
Quoted 69 lines
Signed-off-by Firo Yang <[email protected]>--- arch/arm/plat-pxa/ssp.c | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-)arch/arm/plat-pxa/ssp.c +3
-22@@ -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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 8 lines · Firo Yang
Quoted 7 lines · Julia Lawall
Quoted 5 lines · Firo Yang
A Coccinelle warning.
It's not necessary to free memory allocated withdevm_xxxand using these free functions maybe lead to a double free that will corrupt the resource subsys. So, I just remove them.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
By the way, I replace
devm_request_mem_regionanddevm_ioremapwithdevm_ioremap_resourceas 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
Quoted 80 lines
Quoted 65 lines
julia
Quoted 61 lines
Signed-off-by Firo Yang <[email protected]>--- arch/arm/plat-pxa/ssp.c | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-)arch/arm/plat-pxa/ssp.c +3
-21@@ -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 ; }Quoted 8 lines
Quoted 8 lines
--
2.4.2--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 13 lines · Julia Lawall
Quoted 11 lines · Firo Yang
Quoted 10 lines · Julia Lawall
Quoted 7 lines · Firo Yang
A Coccinelle warning.
It's not necessary to free memory allocated withdevm_xxxand 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_regionanddevm_ioremapwithdevm_ioremap_resourceas Julia's suggestion.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
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?
Quoted 83 lines
julia
Quoted 80 lines
Quoted 65 lines
julia
Quoted 61 lines
Signed-off-by Firo Yang <[email protected]>--- arch/arm/plat-pxa/ssp.c | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-)arch/arm/plat-pxa/ssp.c +3
-21@@ -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 ; }Quoted 8 lines
Quoted 8 lines
--
2.4.2--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 3 lines
Quoted 1 line
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
Quoted 7 lines · Julia Lawall
Quoted 3 lines
Quoted 1 line
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
Quoted 2 lines
julia