2015-06-17 12:00:09

by Masahiro Yamada

[permalink] [raw]
Subject: [PATCH 1/2] gpio: altera: use of_mm_gpiochip_remove() to fix memory leak

This driver calls of_mm_gpiochip_add() to add a memory mapped gpio
chip. So, of_mm_gpiochip_remove() should be used when removing it.

The direct call of gpiochip_remove() misses unmapping the register
and freeing the label.

Signed-off-by: Masahiro Yamada <[email protected]>
---

drivers/gpio/gpio-altera.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-altera.c b/drivers/gpio/gpio-altera.c
index 449fb46..c653c83 100644
--- a/drivers/gpio/gpio-altera.c
+++ b/drivers/gpio/gpio-altera.c
@@ -337,7 +337,7 @@ static int altera_gpio_remove(struct platform_device *pdev)
{
struct altera_gpio_chip *altera_gc = platform_get_drvdata(pdev);

- gpiochip_remove(&altera_gc->mmchip.gc);
+ of_mm_gpiochip_remove(&altera_gc->mmchip);

return -EIO;
}
--
1.9.1


2015-06-17 12:00:15

by Masahiro Yamada

[permalink] [raw]
Subject: [PATCH 2/2] gpio: altera: fix return value of altera_gpio_remove()

The remove callback never succeeds, which seems odd.

Signed-off-by: Masahiro Yamada <[email protected]>
---

I wonder why nobody has pointed this out before me.
I am suspecting -EIO might be intentional.
I hope some Altera guys will give me comments.


drivers/gpio/gpio-altera.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-altera.c b/drivers/gpio/gpio-altera.c
index c653c83..5861550 100644
--- a/drivers/gpio/gpio-altera.c
+++ b/drivers/gpio/gpio-altera.c
@@ -339,7 +339,7 @@ static int altera_gpio_remove(struct platform_device *pdev)

of_mm_gpiochip_remove(&altera_gc->mmchip);

- return -EIO;
+ return 0;
}

static const struct of_device_id altera_gpio_of_match[] = {
--
1.9.1

2015-06-21 07:23:09

by Alexandre Courbot

[permalink] [raw]
Subject: Re: [PATCH 1/2] gpio: altera: use of_mm_gpiochip_remove() to fix memory leak

On Wed, Jun 17, 2015 at 8:59 PM, Masahiro Yamada
<[email protected]> wrote:
> This driver calls of_mm_gpiochip_add() to add a memory mapped gpio
> chip. So, of_mm_gpiochip_remove() should be used when removing it.
>
> The direct call of gpiochip_remove() misses unmapping the register
> and freeing the label.
>
> Signed-off-by: Masahiro Yamada <[email protected]>

Reviewed-by: Alexandre Courbot <[email protected]>

2015-06-21 07:25:52

by Alexandre Courbot

[permalink] [raw]
Subject: Re: [PATCH 2/2] gpio: altera: fix return value of altera_gpio_remove()

On Wed, Jun 17, 2015 at 8:59 PM, Masahiro Yamada
<[email protected]> wrote:
> The remove callback never succeeds, which seems odd.
>
> Signed-off-by: Masahiro Yamada <[email protected]>
> ---
>
> I wonder why nobody has pointed this out before me.
> I am suspecting -EIO might be intentional.
> I hope some Altera guys will give me comments.
>
>
> drivers/gpio/gpio-altera.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpio/gpio-altera.c b/drivers/gpio/gpio-altera.c
> index c653c83..5861550 100644
> --- a/drivers/gpio/gpio-altera.c
> +++ b/drivers/gpio/gpio-altera.c
> @@ -339,7 +339,7 @@ static int altera_gpio_remove(struct platform_device *pdev)
>
> of_mm_gpiochip_remove(&altera_gc->mmchip);
>
> - return -EIO;
> + return 0;

That looks weird indeed. Tien, can you comment on this?

2015-06-22 03:10:25

by Tien Hock Loh

[permalink] [raw]
Subject: Re: [PATCH 2/2] gpio: altera: fix return value of altera_gpio_remove()

Sorry I was away from my mail for the past few weeks.
This isn't intentional, should be a bug I overlook. The fix is correct.

On Sun, 2015-06-21 at 16:25 +0900, Alexandre Courbot wrote:
> On Wed, Jun 17, 2015 at 8:59 PM, Masahiro Yamada
> <[email protected]> wrote:
> > The remove callback never succeeds, which seems odd.
> >
> > Signed-off-by: Masahiro Yamada <[email protected]>
> > ---
> >
> > I wonder why nobody has pointed this out before me.
> > I am suspecting -EIO might be intentional.
> > I hope some Altera guys will give me comments.
> >
> >
> > drivers/gpio/gpio-altera.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/gpio/gpio-altera.c b/drivers/gpio/gpio-altera.c
> > index c653c83..5861550 100644
> > --- a/drivers/gpio/gpio-altera.c
> > +++ b/drivers/gpio/gpio-altera.c
> > @@ -339,7 +339,7 @@ static int altera_gpio_remove(struct platform_device *pdev)
> >
> > of_mm_gpiochip_remove(&altera_gc->mmchip);
> >
> > - return -EIO;
> > + return 0;
>
> That looks weird indeed. Tien, can you comment on this?

2015-06-22 02:26:00

by Alexandre Courbot

[permalink] [raw]
Subject: Re: [PATCH 2/2] gpio: altera: fix return value of altera_gpio_remove()

On Mon, Jun 22, 2015 at 10:36 AM, Tien Hock Loh <[email protected]> wrote:
> Sorry I was away from my mail for the past few weeks.
> This isn't intentional, should be a bug I overlook. The fix is correct.

Interestingly that has never been caught by reviewers despite 10
respins of your series!

Thanks for confirming.

Reviewed-by: Alexandre Courbot <[email protected]>

>
> On Sun, 2015-06-21 at 16:25 +0900, Alexandre Courbot wrote:
>> On Wed, Jun 17, 2015 at 8:59 PM, Masahiro Yamada
>> <[email protected]> wrote:
>> > The remove callback never succeeds, which seems odd.
>> >
>> > Signed-off-by: Masahiro Yamada <[email protected]>
>> > ---
>> >
>> > I wonder why nobody has pointed this out before me.
>> > I am suspecting -EIO might be intentional.
>> > I hope some Altera guys will give me comments.
>> >
>> >
>> > drivers/gpio/gpio-altera.c | 2 +-
>> > 1 file changed, 1 insertion(+), 1 deletion(-)
>> >
>> > diff --git a/drivers/gpio/gpio-altera.c b/drivers/gpio/gpio-altera.c
>> > index c653c83..5861550 100644
>> > --- a/drivers/gpio/gpio-altera.c
>> > +++ b/drivers/gpio/gpio-altera.c
>> > @@ -339,7 +339,7 @@ static int altera_gpio_remove(struct platform_device *pdev)
>> >
>> > of_mm_gpiochip_remove(&altera_gc->mmchip);
>> >
>> > - return -EIO;
>> > + return 0;
>>
>> That looks weird indeed. Tien, can you comment on this?
>

2015-06-22 10:04:55

by Masahiro Yamada

[permalink] [raw]
Subject: Re: [PATCH 2/2] gpio: altera: fix return value of altera_gpio_remove()

Hi Tien,


2015-06-22 10:36 GMT+09:00 Tien Hock Loh <[email protected]>:
> Sorry I was away from my mail for the past few weeks.
> This isn't intentional, should be a bug I overlook. The fix is correct.
>

OK, then could you issue your Acked-by credit?


Also, do the followings look good?

http://patchwork.ozlabs.org/patch/485370/
http://patchwork.ozlabs.org/patch/486669/

Thanks.

--
Best Regards
Masahiro Yamada

2015-06-26 03:16:55

by Tien Hock Loh

[permalink] [raw]
Subject: Re: [PATCH 2/2] gpio: altera: fix return value of altera_gpio_remove()

Acked-by: Tien Hock Loh <[email protected]>

On Wed, 2015-06-17 at 20:59 +0900, Masahiro Yamada wrote:
> The remove callback never succeeds, which seems odd.
>
> Signed-off-by: Masahiro Yamada <[email protected]>
> ---
>
> I wonder why nobody has pointed this out before me.
> I am suspecting -EIO might be intentional.
> I hope some Altera guys will give me comments.
>
>
> drivers/gpio/gpio-altera.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpio/gpio-altera.c b/drivers/gpio/gpio-altera.c
> index c653c83..5861550 100644
> --- a/drivers/gpio/gpio-altera.c
> +++ b/drivers/gpio/gpio-altera.c
> @@ -339,7 +339,7 @@ static int altera_gpio_remove(struct platform_device *pdev)
>
> of_mm_gpiochip_remove(&altera_gc->mmchip);
>
> - return -EIO;
> + return 0;
> }
>
> static const struct of_device_id altera_gpio_of_match[] = {

2015-06-26 03:51:52

by Tien Hock Loh

[permalink] [raw]
Subject: Re: [PATCH 1/2] gpio: altera: use of_mm_gpiochip_remove() to fix memory leak

Acked-by: Tien Hock Loh <[email protected]>

On Wed, 2015-06-17 at 20:59 +0900, Masahiro Yamada wrote:
> This driver calls of_mm_gpiochip_add() to add a memory mapped gpio
> chip. So, of_mm_gpiochip_remove() should be used when removing it.
>
> The direct call of gpiochip_remove() misses unmapping the register
> and freeing the label.
>
> Signed-off-by: Masahiro Yamada <[email protected]>
> ---
>
> drivers/gpio/gpio-altera.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpio/gpio-altera.c b/drivers/gpio/gpio-altera.c
> index 449fb46..c653c83 100644
> --- a/drivers/gpio/gpio-altera.c
> +++ b/drivers/gpio/gpio-altera.c
> @@ -337,7 +337,7 @@ static int altera_gpio_remove(struct platform_device *pdev)
> {
> struct altera_gpio_chip *altera_gc = platform_get_drvdata(pdev);
>
> - gpiochip_remove(&altera_gc->mmchip.gc);
> + of_mm_gpiochip_remove(&altera_gc->mmchip);
>
> return -EIO;
> }

2015-07-15 09:45:35

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH 1/2] gpio: altera: use of_mm_gpiochip_remove() to fix memory leak

On Wed, Jun 17, 2015 at 1:59 PM, Masahiro Yamada
<[email protected]> wrote:

> This driver calls of_mm_gpiochip_add() to add a memory mapped gpio
> chip. So, of_mm_gpiochip_remove() should be used when removing it.
>
> The direct call of gpiochip_remove() misses unmapping the register
> and freeing the label.
>
> Signed-off-by: Masahiro Yamada <[email protected]>

Patch applied with the ACKs.

Yours,
Linus Walleij