From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: "Michał Kępień" <kernel@kempniu.pl>,
linux-input <linux-input@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"Platform Driver" <platform-driver-x86@vger.kernel.org>,
"Andy Shevchenko" <andy@infradead.org>
Subject: Re: [PATCH v3] Input: sparse-keymap - use a managed allocation for keymap copy
Date: Wed, 8 Mar 2017 13:05:06 -0800 [thread overview]
Message-ID: <20170308210506.GD20567@dtor-ws> (raw)
In-Reply-To: <CAHp75VdjQS_D5=gZ5Ei1quqjqyhPADxeT=a832Mb+Sk1kDz0mQ@mail.gmail.com>
On Wed, Mar 08, 2017 at 10:50:16PM +0200, Andy Shevchenko wrote:
> On Wed, Mar 8, 2017 at 8:12 PM, Dmitry Torokhov
> <dmitry.torokhov@gmail.com> wrote:
> > On Wed, Mar 08, 2017 at 09:22:17AM +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, make
> >> sparse_keymap_setup() use devm_kmemdup() to create the keymap copy so
> >> that it gets automatically freed.
> >>
> >> This works for both managed and non-managed input devices as the keymap
> >> is freed after the last reference to the input device is dropped.
> >>
> >> Note that actions previously taken by sparse_keymap_free(), i.e. taking
> >> the input device's mutex and zeroing its keycode and keycodemax fields,
> >> are now redundant because the managed keymap will always be freed after
> >> the input device is unregistered.
>
> > OK, I think this looks good. Do platform folks want an immutable branch
> > off 4.10 with this change so we can start cleaning sparse_keymap_free()
> > users in this cycle?
>
> If there PDx86 related patches are anticipated this cycle, definitely
> we need an immutable branch (perhaps based on v4.11-rc1).
OK, I'll make one (based on 4.10 final - the patch should apply cleanly
there and there is no point of forcing anyone's workflow to use kernel
in the beginning of stabilization cycle).
As to whether there are PDx86 patches - I hope Michał will supply them
;) I'll take care of the 2 instances in drivers/input/misc.
Thanks.
--
Dmitry
next prev parent reply other threads:[~2017-03-08 21:05 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-08 8:22 [PATCH v3] Input: sparse-keymap - use a managed allocation for keymap copy Michał Kępień
2017-03-08 18:12 ` Dmitry Torokhov
2017-03-08 20:50 ` Andy Shevchenko
2017-03-08 21:05 ` Dmitry Torokhov [this message]
2017-03-08 21:47 ` Andy Shevchenko
2017-03-09 7:58 ` Michał Kępień
2017-03-09 18:08 ` 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=20170308210506.GD20567@dtor-ws \
--to=dmitry.torokhov@gmail.com \
--cc=andy.shevchenko@gmail.com \
--cc=andy@infradead.org \
--cc=kernel@kempniu.pl \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=platform-driver-x86@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;
as well as URLs for NNTP newsgroup(s).