From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: "Michał Kępień" <kernel@kempniu.pl>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Input: sparse-keymap - add managed version of sparse_keymap_setup()
Date: Tue, 28 Feb 2017 10:45:58 -0800 [thread overview]
Message-ID: <20170228184558.GG20776@dtor-ws> (raw)
In-Reply-To: <20170228094525.26683-1-kernel@kempniu.pl>
On Tue, Feb 28, 2017 at 10:45:25AM +0100, Michał Kępień wrote:
> Some platform drivers use devm_input_allocate_device() together with
> sparse_keymap_setup() in their .probe callbacks. While using the former
> simplifies error handling, using the latter necessitates calling
> sparse_keymap_free() in the error path and upon module unloading to
> avoid leaking the copy of the keymap allocated by sparse_keymap_setup().
>
> To help prevent such leaks and enable simpler error handling in these
> drivers, add a new function which allows automatic freeing of the keymap
> copy upon probe failure and on driver detach.
>
> As devm_input_allocate_device() adds its devres to the device owning the
> input device, we do the same for managed input devices to ensure freeing
> the keymap copy is properly slotted in the devres stack.
>
> The new function can also be used by non-managed input devices, though
> in this case the devres is attached to the struct device embedded inside
> the input device itself.
This is wrong and does not work as input devices are never probed and
never unbound, so the cleanup will never happen.
Either pass device explicitly, or always take input's parent.
Thanks.
--
Dmitry
next prev parent reply other threads:[~2017-02-28 18:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-28 9:45 [PATCH] Input: sparse-keymap - add managed version of sparse_keymap_setup() Michał Kępień
2017-02-28 18:45 ` Dmitry Torokhov [this message]
2017-03-01 10:37 ` Michał Kępień
2017-03-01 18:19 ` Dmitry Torokhov
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=20170228184558.GG20776@dtor-ws \
--to=dmitry.torokhov@gmail.com \
--cc=kernel@kempniu.pl \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.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