From: Hans de Goede <hdegoede@redhat.com>
To: "José Expósito" <jose.exposito89@gmail.com>, hadess@hadess.net
Cc: dmitry.torokhov@gmail.com, rydberg@bitmath.org, lains@riseup.net,
jikos@kernel.org, benjamin.tissoires@redhat.com,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] HID: wacom: Fix double free on managed resource
Date: Sat, 23 Apr 2022 13:42:12 +0200 [thread overview]
Message-ID: <e6f914ca-5863-c983-b2fe-7bda7262fb1d@redhat.com> (raw)
In-Reply-To: <20220422161709.30198-3-jose.exposito89@gmail.com>
Hi,
On 4/22/22 18:17, José Expósito wrote:
> As described in the documentation for devm_input_allocate_device():
>
> Managed input devices do not need to be explicitly unregistered or
> freed as it will be done automatically when owner device unbinds from
> its driver (or binding fails).
>
> However this driver was explicitly freeing the input device, allocated
> using devm_input_allocate_device() through wacom_allocate_input().
>
> Remove the calls to input_free_device() to avoid a possible double free
> error.
Actually calling input_free_device() on a devm allocated input device
is fine. The input subsystem has chosen to not have a
separate devm_input_free_device(), instead input_free_device() knows
if a device is allocated through devm and then also frees the devres
tied to it:
void input_free_device(struct input_dev *dev)
{
if (dev) {
if (dev->devres_managed)
WARN_ON(devres_destroy(dev->dev.parent,
devm_input_device_release,
devm_input_device_match,
dev));
input_put_device(dev);
}
}
So there is no need for this patch.
Regards,
Hans
>
> Fixes: d2d13f18aaa51 ("Input: wacom - create a separate input device for pads")
> Signed-off-by: José Expósito <jose.exposito89@gmail.com>
> ---
> drivers/hid/wacom_sys.c | 3 ---
> 1 file changed, 3 deletions(-)
>
> diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
> index 066c567dbaa2..164c0f7cb796 100644
> --- a/drivers/hid/wacom_sys.c
> +++ b/drivers/hid/wacom_sys.c
> @@ -2098,7 +2098,6 @@ static int wacom_register_inputs(struct wacom *wacom)
> error = wacom_setup_pen_input_capabilities(pen_input_dev, wacom_wac);
> if (error) {
> /* no pen in use on this interface */
> - input_free_device(pen_input_dev);
> wacom_wac->pen_input = NULL;
> pen_input_dev = NULL;
> } else {
> @@ -2110,7 +2109,6 @@ static int wacom_register_inputs(struct wacom *wacom)
> error = wacom_setup_touch_input_capabilities(touch_input_dev, wacom_wac);
> if (error) {
> /* no touch in use on this interface */
> - input_free_device(touch_input_dev);
> wacom_wac->touch_input = NULL;
> touch_input_dev = NULL;
> } else {
> @@ -2122,7 +2120,6 @@ static int wacom_register_inputs(struct wacom *wacom)
> error = wacom_setup_pad_input_capabilities(pad_input_dev, wacom_wac);
> if (error) {
> /* no pad in use on this interface */
> - input_free_device(pad_input_dev);
> wacom_wac->pad_input = NULL;
> pad_input_dev = NULL;
> } else {
next prev parent reply other threads:[~2022-04-23 11:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-22 16:17 [PATCH 1/3] Input: goodix - Fix double free on managed resource José Expósito
2022-04-22 16:17 ` [PATCH 2/3] HID: logitech-hidpp: " José Expósito
2022-04-23 11:41 ` Hans de Goede
2022-04-23 15:02 ` José Expósito
2022-04-22 16:17 ` [PATCH 3/3] HID: wacom: " José Expósito
2022-04-23 11:42 ` Hans de Goede [this message]
2022-04-23 11:34 ` [PATCH 1/3] Input: goodix - " Hans de Goede
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=e6f914ca-5863-c983-b2fe-7bda7262fb1d@redhat.com \
--to=hdegoede@redhat.com \
--cc=benjamin.tissoires@redhat.com \
--cc=dmitry.torokhov@gmail.com \
--cc=hadess@hadess.net \
--cc=jikos@kernel.org \
--cc=jose.exposito89@gmail.com \
--cc=lains@riseup.net \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rydberg@bitmath.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).