linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: rydberg@euromail.se, tj@kernel.org, linux-input@vger.kernel.org,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] Input: Fix a ref counting issue
Date: Sun, 29 Nov 2020 11:49:18 -0800	[thread overview]
Message-ID: <20201129194918.GL2034289@dtor-ws> (raw)
In-Reply-To: <20201129084516.1456099-1-christophe.jaillet@wanadoo.fr>

Hi Christophe,

On Sun, Nov 29, 2020 at 09:45:16AM +0100, Christophe JAILLET wrote:
> In case of a managed resource, 'devm_input_device_release()' already has a
> 'input_put_device(dev)' call.
> 
> Avoid a double reference decrement by explicitly calling
> 'input_put_device()' only on non-managed input device.

This patch is incorrect, as devres_destroy() that is used in
input_free_device(), unlike devres_releasde(), does not actually call
the "release" function. It simply destroys the devres object, but does
not clear associated resources.

> 
> Fixes: 2be975c6d920 ("Input: introduce managed input devices (add devres support)")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> This patch is completely speculative and compile tested only.
> ---
>  drivers/input/input.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/input/input.c b/drivers/input/input.c
> index 3cfd2c18eebd..c09c9f020667 100644
> --- a/drivers/input/input.c
> +++ b/drivers/input/input.c
> @@ -1920,7 +1920,8 @@ void input_free_device(struct input_dev *dev)
>  						devm_input_device_release,
>  						devm_input_device_match,
>  						dev));
> -		input_put_device(dev);
> +		else
> +			input_put_device(dev);
>  	}
>  }
>  EXPORT_SYMBOL(input_free_device);
> -- 
> 2.27.0
> 

Thanks.

-- 
Dmitry

  reply	other threads:[~2020-11-29 19:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-29  8:45 [PATCH] Input: Fix a ref counting issue Christophe JAILLET
2020-11-29 19:49 ` Dmitry Torokhov [this message]
2020-11-29 20:14   ` Christophe JAILLET

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=20201129194918.GL2034289@dtor-ws \
    --to=dmitry.torokhov@gmail.com \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rydberg@euromail.se \
    --cc=tj@kernel.org \
    /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).