Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1505299 > unrolled thread

[PATCH] Input: gpio_keys_polled - fix DT node reference leak

Started byDmitry Torokhov <dmitry.torokhov@gmail.com>
First post2016-10-21 00:10 +0200
Last post2016-10-27 03:10 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] Input: gpio_keys_polled - fix DT node reference leak Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2016-10-21 00:10 +0200
    Re: [PATCH] Input: gpio_keys_polled - fix DT node reference leak Mika Westerberg <mika.westerberg@linux.intel.com> - 2016-10-21 11:10 +0200
      Re: [PATCH] Input: gpio_keys_polled - fix DT node reference leak Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2016-10-27 03:10 +0200

#1505299 — [PATCH] Input: gpio_keys_polled - fix DT node reference leak

FromDmitry Torokhov <dmitry.torokhov@gmail.com>
Date2016-10-21 00:10 +0200
Subject[PATCH] Input: gpio_keys_polled - fix DT node reference leak
Message-ID<sutHc-52m-43@gated-at.bofh.it>
When someone requests button with wakeup (which this driver does not
support) we should drop reference to the current child device node before
returning error.

Note that when we using legacy platform data 'child' stays NULL which
fwnode_handle_put() handles just fine.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/input/keyboard/gpio_keys_polled.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/input/keyboard/gpio_keys_polled.c b/drivers/input/keyboard/gpio_keys_polled.c
index 270dcf7..72b3503 100644
--- a/drivers/input/keyboard/gpio_keys_polled.c
+++ b/drivers/input/keyboard/gpio_keys_polled.c
@@ -291,6 +291,7 @@ static int gpio_keys_polled_probe(struct platform_device *pdev)
 
 		if (button->wakeup) {
 			dev_err(dev, DRV_NAME " does not support wakeup\n");
+			fwnode_handle_put(child);
 			return -EINVAL;
 		}
 
-- 
2.8.0.rc3.226.g39d4020


-- 
Dmitry

[toc] | [next] | [standalone]


#1505603

FromMika Westerberg <mika.westerberg@linux.intel.com>
Date2016-10-21 11:10 +0200
Message-ID<suDZT-3tk-3@gated-at.bofh.it>
In reply to#1505299
On Thu, Oct 20, 2016 at 03:06:36PM -0700, Dmitry Torokhov wrote:
> When someone requests button with wakeup (which this driver does not
> support) we should drop reference to the current child device node before
> returning error.
> 
> Note that when we using legacy platform data 'child' stays NULL which
> fwnode_handle_put() handles just fine.
> 
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
>  drivers/input/keyboard/gpio_keys_polled.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/input/keyboard/gpio_keys_polled.c b/drivers/input/keyboard/gpio_keys_polled.c
> index 270dcf7..72b3503 100644
> --- a/drivers/input/keyboard/gpio_keys_polled.c
> +++ b/drivers/input/keyboard/gpio_keys_polled.c
> @@ -291,6 +291,7 @@ static int gpio_keys_polled_probe(struct platform_device *pdev)
>  
>  		if (button->wakeup) {
>  			dev_err(dev, DRV_NAME " does not support wakeup\n");
> +			fwnode_handle_put(child);

Are you sure this is the right place?

I didn't try to compile this but to me it looks like there is no
variable named "child" in the whole gpio_keys_polled_probe() function.
Unless I'm looking at wrong branch ;-)

>  			return -EINVAL;
>  		}
>  
> -- 
> 2.8.0.rc3.226.g39d4020
> 
> 
> -- 
> Dmitry

[toc] | [prev] | [next] | [standalone]


#1510002

FromDmitry Torokhov <dmitry.torokhov@gmail.com>
Date2016-10-27 03:10 +0200
Message-ID<swHmF-3ev-17@gated-at.bofh.it>
In reply to#1505603
On Fri, Oct 21, 2016 at 12:02:35PM +0300, Mika Westerberg wrote:
> On Thu, Oct 20, 2016 at 03:06:36PM -0700, Dmitry Torokhov wrote:
> > When someone requests button with wakeup (which this driver does not
> > support) we should drop reference to the current child device node before
> > returning error.
> > 
> > Note that when we using legacy platform data 'child' stays NULL which
> > fwnode_handle_put() handles just fine.
> > 
> > Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > ---
> >  drivers/input/keyboard/gpio_keys_polled.c | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/drivers/input/keyboard/gpio_keys_polled.c b/drivers/input/keyboard/gpio_keys_polled.c
> > index 270dcf7..72b3503 100644
> > --- a/drivers/input/keyboard/gpio_keys_polled.c
> > +++ b/drivers/input/keyboard/gpio_keys_polled.c
> > @@ -291,6 +291,7 @@ static int gpio_keys_polled_probe(struct platform_device *pdev)
> >  
> >  		if (button->wakeup) {
> >  			dev_err(dev, DRV_NAME " does not support wakeup\n");
> > +			fwnode_handle_put(child);
> 
> Are you sure this is the right place?
> 
> I didn't try to compile this but to me it looks like there is no
> variable named "child" in the whole gpio_keys_polled_probe() function.
> Unless I'm looking at wrong branch ;-)

Hmm, it was on top of my other change. I though I already published it,
but since it turns out I didn't I will just fold this one in.

Thanks.

-- 
Dmitry

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web