linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Arvind Yadav <arvind.yadav.cs@gmail.com>
Cc: linux@roeck-us.net, linux-kernel@vger.kernel.org,
	linux-input@vger.kernel.org
Subject: Re: [PATCH] Input: davinci_keyscan: Free memory occupied by davinci key scan device
Date: Tue, 14 Nov 2017 10:14:34 -0800	[thread overview]
Message-ID: <20171114181434.lpwhojwemzdruet6@dtor-ws> (raw)
In-Reply-To: <9203eaebf020cbebf5224221d789a0163490d654.1510666872.git.arvind.yadav.cs@gmail.com>

On Tue, Nov 14, 2017 at 07:15:14PM +0530, Arvind Yadav wrote:
> Here, key_dev is NULL in input_free_device() and It will not free
> memory occupied by davinci key scan device. Move "key_dev = NULL"
> after input_free_device().

No, this is absolutely wrong. It is disallowed to call
input_free_device() after calling input_unregister_device(), because
input core will free the device once the last reference is dropped. That
is why we set "key_dev" to NULL to turn input_free_device() into a noop.

> 
> Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
> ---
>  drivers/input/keyboard/davinci_keyscan.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/input/keyboard/davinci_keyscan.c b/drivers/input/keyboard/davinci_keyscan.c
> index b20a5d0..22cb8d2 100644
> --- a/drivers/input/keyboard/davinci_keyscan.c
> +++ b/drivers/input/keyboard/davinci_keyscan.c
> @@ -290,13 +290,13 @@ static int __init davinci_ks_probe(struct platform_device *pdev)
>  	free_irq(davinci_ks->irq, davinci_ks);
>  fail5:
>  	input_unregister_device(davinci_ks->input);
> -	key_dev = NULL;
>  fail4:
>  	iounmap(davinci_ks->base);
>  fail3:
>  	release_mem_region(davinci_ks->pbase, davinci_ks->base_size);
>  fail2:
>  	input_free_device(key_dev);
> +	key_dev = NULL;
>  fail1:
>  	kfree(davinci_ks);
>  
> -- 
> 1.9.1
> 

Thanks.

-- 
Dmitry

  reply	other threads:[~2017-11-14 18:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-14 13:45 [PATCH] Input: davinci_keyscan: Free memory occupied by davinci key scan device Arvind Yadav
2017-11-14 18:14 ` Dmitry Torokhov [this message]
2017-11-14 18:40   ` arvindY

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171114181434.lpwhojwemzdruet6@dtor-ws \
    --to=dmitry.torokhov@gmail.com \
    --cc=arvind.yadav.cs@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).