* [PATCH] ARM: mmp: Fix failure to remove sram device
@ 2021-07-26 20:01 Uwe Kleine-König
2021-08-05 11:16 ` Greg Kroah-Hartman
2022-02-21 12:14 ` Uwe Kleine-König
0 siblings, 2 replies; 6+ messages in thread
From: Uwe Kleine-König @ 2021-07-26 20:01 UTC (permalink / raw)
To: Lubomir Rintel, Russell King; +Cc: kernel, Greg Kroah-Hartman, linux-arm-kernel
Make sure in .probe() to set driver data before the function is left to
make it possible in .remove() to undo the actions done.
This fixes a potential memory leak and stops returning an error code in
.remove() that is ignored by the driver core anyhow.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
arch/arm/mach-mmp/sram.c | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/arch/arm/mach-mmp/sram.c b/arch/arm/mach-mmp/sram.c
index 6794e2db1ad5..ecc46c31004f 100644
--- a/arch/arm/mach-mmp/sram.c
+++ b/arch/arm/mach-mmp/sram.c
@@ -72,6 +72,8 @@ static int sram_probe(struct platform_device *pdev)
if (!info)
return -ENOMEM;
+ platform_set_drvdata(pdev, info);
+
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (res == NULL) {
dev_err(&pdev->dev, "no memory resource defined\n");
@@ -107,8 +109,6 @@ static int sram_probe(struct platform_device *pdev)
list_add(&info->node, &sram_bank_list);
mutex_unlock(&sram_lock);
- platform_set_drvdata(pdev, info);
-
dev_info(&pdev->dev, "initialized\n");
return 0;
@@ -127,17 +127,19 @@ static int sram_remove(struct platform_device *pdev)
struct sram_bank_info *info;
info = platform_get_drvdata(pdev);
- if (info == NULL)
- return -ENODEV;
- mutex_lock(&sram_lock);
- list_del(&info->node);
- mutex_unlock(&sram_lock);
+ if (info->sram_size) {
+ mutex_lock(&sram_lock);
+ list_del(&info->node);
+ mutex_unlock(&sram_lock);
+
+ gen_pool_destroy(info->gpool);
+ iounmap(info->sram_virt);
+ kfree(info->pool_name);
+ }
- gen_pool_destroy(info->gpool);
- iounmap(info->sram_virt);
- kfree(info->pool_name);
kfree(info);
+
return 0;
}
--
2.30.2
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] ARM: mmp: Fix failure to remove sram device
2021-07-26 20:01 [PATCH] ARM: mmp: Fix failure to remove sram device Uwe Kleine-König
@ 2021-08-05 11:16 ` Greg Kroah-Hartman
2022-02-21 12:14 ` Uwe Kleine-König
1 sibling, 0 replies; 6+ messages in thread
From: Greg Kroah-Hartman @ 2021-08-05 11:16 UTC (permalink / raw)
To: Uwe Kleine-König
Cc: Lubomir Rintel, Russell King, kernel, linux-arm-kernel
On Mon, Jul 26, 2021 at 10:01:58PM +0200, Uwe Kleine-König wrote:
> Make sure in .probe() to set driver data before the function is left to
> make it possible in .remove() to undo the actions done.
>
> This fixes a potential memory leak and stops returning an error code in
> .remove() that is ignored by the driver core anyhow.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
> arch/arm/mach-mmp/sram.c | 22 ++++++++++++----------
> 1 file changed, 12 insertions(+), 10 deletions(-)
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] ARM: mmp: Fix failure to remove sram device
2021-07-26 20:01 [PATCH] ARM: mmp: Fix failure to remove sram device Uwe Kleine-König
@ 2022-02-21 12:14 ` Uwe Kleine-König
2022-02-21 12:14 ` Uwe Kleine-König
1 sibling, 0 replies; 6+ messages in thread
From: Uwe Kleine-König @ 2022-02-21 12:14 UTC (permalink / raw)
To: Lubomir Rintel, Russell King
Cc: Greg Kroah-Hartman, linux-arm-kernel, kernel, soc
[-- Attachment #1: Type: text/plain, Size: 2236 bytes --]
[adding soc@kernel.org to Cc]
On Mon, Jul 26, 2021 at 10:01:58PM +0200, Uwe Kleine-König wrote:
> Make sure in .probe() to set driver data before the function is left to
> make it possible in .remove() to undo the actions done.
>
> This fixes a potential memory leak and stops returning an error code in
> .remove() that is ignored by the driver core anyhow.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
This problem is still real and the patch not applied. Who feels
responsible to pick this up?
> ---
> arch/arm/mach-mmp/sram.c | 22 ++++++++++++----------
> 1 file changed, 12 insertions(+), 10 deletions(-)
>
> diff --git a/arch/arm/mach-mmp/sram.c b/arch/arm/mach-mmp/sram.c
> index 6794e2db1ad5..ecc46c31004f 100644
> --- a/arch/arm/mach-mmp/sram.c
> +++ b/arch/arm/mach-mmp/sram.c
> @@ -72,6 +72,8 @@ static int sram_probe(struct platform_device *pdev)
> if (!info)
> return -ENOMEM;
>
> + platform_set_drvdata(pdev, info);
> +
> res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> if (res == NULL) {
> dev_err(&pdev->dev, "no memory resource defined\n");
> @@ -107,8 +109,6 @@ static int sram_probe(struct platform_device *pdev)
> list_add(&info->node, &sram_bank_list);
> mutex_unlock(&sram_lock);
>
> - platform_set_drvdata(pdev, info);
> -
> dev_info(&pdev->dev, "initialized\n");
> return 0;
>
> @@ -127,17 +127,19 @@ static int sram_remove(struct platform_device *pdev)
> struct sram_bank_info *info;
>
> info = platform_get_drvdata(pdev);
> - if (info == NULL)
> - return -ENODEV;
>
> - mutex_lock(&sram_lock);
> - list_del(&info->node);
> - mutex_unlock(&sram_lock);
> + if (info->sram_size) {
> + mutex_lock(&sram_lock);
> + list_del(&info->node);
> + mutex_unlock(&sram_lock);
> +
> + gen_pool_destroy(info->gpool);
> + iounmap(info->sram_virt);
> + kfree(info->pool_name);
> + }
>
> - gen_pool_destroy(info->gpool);
> - iounmap(info->sram_virt);
> - kfree(info->pool_name);
> kfree(info);
> +
> return 0;
> }
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] ARM: mmp: Fix failure to remove sram device
@ 2022-02-21 12:14 ` Uwe Kleine-König
0 siblings, 0 replies; 6+ messages in thread
From: Uwe Kleine-König @ 2022-02-21 12:14 UTC (permalink / raw)
To: Lubomir Rintel, Russell King
Cc: Greg Kroah-Hartman, linux-arm-kernel, kernel, soc
[-- Attachment #1.1: Type: text/plain, Size: 2236 bytes --]
[adding soc@kernel.org to Cc]
On Mon, Jul 26, 2021 at 10:01:58PM +0200, Uwe Kleine-König wrote:
> Make sure in .probe() to set driver data before the function is left to
> make it possible in .remove() to undo the actions done.
>
> This fixes a potential memory leak and stops returning an error code in
> .remove() that is ignored by the driver core anyhow.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
This problem is still real and the patch not applied. Who feels
responsible to pick this up?
> ---
> arch/arm/mach-mmp/sram.c | 22 ++++++++++++----------
> 1 file changed, 12 insertions(+), 10 deletions(-)
>
> diff --git a/arch/arm/mach-mmp/sram.c b/arch/arm/mach-mmp/sram.c
> index 6794e2db1ad5..ecc46c31004f 100644
> --- a/arch/arm/mach-mmp/sram.c
> +++ b/arch/arm/mach-mmp/sram.c
> @@ -72,6 +72,8 @@ static int sram_probe(struct platform_device *pdev)
> if (!info)
> return -ENOMEM;
>
> + platform_set_drvdata(pdev, info);
> +
> res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> if (res == NULL) {
> dev_err(&pdev->dev, "no memory resource defined\n");
> @@ -107,8 +109,6 @@ static int sram_probe(struct platform_device *pdev)
> list_add(&info->node, &sram_bank_list);
> mutex_unlock(&sram_lock);
>
> - platform_set_drvdata(pdev, info);
> -
> dev_info(&pdev->dev, "initialized\n");
> return 0;
>
> @@ -127,17 +127,19 @@ static int sram_remove(struct platform_device *pdev)
> struct sram_bank_info *info;
>
> info = platform_get_drvdata(pdev);
> - if (info == NULL)
> - return -ENODEV;
>
> - mutex_lock(&sram_lock);
> - list_del(&info->node);
> - mutex_unlock(&sram_lock);
> + if (info->sram_size) {
> + mutex_lock(&sram_lock);
> + list_del(&info->node);
> + mutex_unlock(&sram_lock);
> +
> + gen_pool_destroy(info->gpool);
> + iounmap(info->sram_virt);
> + kfree(info->pool_name);
> + }
>
> - gen_pool_destroy(info->gpool);
> - iounmap(info->sram_virt);
> - kfree(info->pool_name);
> kfree(info);
> +
> return 0;
> }
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
[-- Attachment #2: Type: text/plain, Size: 176 bytes --]
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] ARM: mmp: Fix failure to remove sram device
2022-02-21 12:14 ` Uwe Kleine-König
@ 2022-02-25 15:40 ` Arnd Bergmann
-1 siblings, 0 replies; 6+ messages in thread
From: Arnd Bergmann @ 2022-02-25 15:40 UTC (permalink / raw)
To: Uwe Kleine-König
Cc: Lubomir Rintel, Russell King, Greg Kroah-Hartman, Linux ARM,
Sascha Hauer, SoC Team
On Mon, Feb 21, 2022 at 1:14 PM Uwe Kleine-König
<u.kleine-koenig@pengutronix.de> wrote:
>
> [adding soc@kernel.org to Cc]
>
> On Mon, Jul 26, 2021 at 10:01:58PM +0200, Uwe Kleine-König wrote:
> > Make sure in .probe() to set driver data before the function is left to
> > make it possible in .remove() to undo the actions done.
> >
> > This fixes a potential memory leak and stops returning an error code in
> > .remove() that is ignored by the driver core anyhow.
> >
> > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
>
> This problem is still real and the patch not applied. Who feels
> responsible to pick this up?
I've picked it up manually now, thank you for looping us in.
Note that I almost missed it again though, if you really want my attention,
send the patch to:soc@kernel.org so it makes it into patchwork. At that
point, I'll have to either apply it or actively discard the patch from there.
Arnd
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] ARM: mmp: Fix failure to remove sram device
@ 2022-02-25 15:40 ` Arnd Bergmann
0 siblings, 0 replies; 6+ messages in thread
From: Arnd Bergmann @ 2022-02-25 15:40 UTC (permalink / raw)
To: Uwe Kleine-König
Cc: Lubomir Rintel, Russell King, Greg Kroah-Hartman, Linux ARM,
Sascha Hauer, SoC Team
On Mon, Feb 21, 2022 at 1:14 PM Uwe Kleine-König
<u.kleine-koenig@pengutronix.de> wrote:
>
> [adding soc@kernel.org to Cc]
>
> On Mon, Jul 26, 2021 at 10:01:58PM +0200, Uwe Kleine-König wrote:
> > Make sure in .probe() to set driver data before the function is left to
> > make it possible in .remove() to undo the actions done.
> >
> > This fixes a potential memory leak and stops returning an error code in
> > .remove() that is ignored by the driver core anyhow.
> >
> > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
>
> This problem is still real and the patch not applied. Who feels
> responsible to pick this up?
I've picked it up manually now, thank you for looping us in.
Note that I almost missed it again though, if you really want my attention,
send the patch to:soc@kernel.org so it makes it into patchwork. At that
point, I'll have to either apply it or actively discard the patch from there.
Arnd
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-02-25 15:42 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-26 20:01 [PATCH] ARM: mmp: Fix failure to remove sram device Uwe Kleine-König
2021-08-05 11:16 ` Greg Kroah-Hartman
2022-02-21 12:14 ` Uwe Kleine-König
2022-02-21 12:14 ` Uwe Kleine-König
2022-02-25 15:40 ` Arnd Bergmann
2022-02-25 15:40 ` Arnd Bergmann
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.