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 1/3] Input: goodix - Fix double free on managed resource
Date: Sat, 23 Apr 2022 13:34:46 +0200 [thread overview]
Message-ID: <c4f8bfef-1cb6-d7bb-dfe1-04b3d952738a@redhat.com> (raw)
In-Reply-To: <20220422161709.30198-1-jose.exposito89@gmail.com>
Hi José,
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.
>
> Remove the calls to input_free_device() to avoid a possible double free
> error.
>
> Fixes: 5ede7f0cfb93f ("Input: goodix - add pen support")
> Signed-off-by: José Expósito <jose.exposito89@gmail.com>
> ---
> drivers/input/touchscreen/goodix.c | 8 ++------
> 1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c
> index 752e8ba4fecb..61eb69f3a259 100644
> --- a/drivers/input/touchscreen/goodix.c
> +++ b/drivers/input/touchscreen/goodix.c
> @@ -308,10 +308,8 @@ static struct input_dev *goodix_create_pen_input(struct goodix_ts_data *ts)
> return NULL;
>
> input_alloc_absinfo(input);
> - if (!input->absinfo) {
> - input_free_device(input);
> + if (!input->absinfo)
> return NULL;
> - }
>
> input->absinfo[ABS_X] = ts->input_dev->absinfo[ABS_MT_POSITION_X];
> input->absinfo[ABS_Y] = ts->input_dev->absinfo[ABS_MT_POSITION_Y];
I don't know what tree you've based this on, but the above code has been replaced
with the new input_copy_abs helper in Linus' current master branch:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/input/touchscreen/goodix.c#n310
> @@ -340,10 +338,8 @@ static struct input_dev *goodix_create_pen_input(struct goodix_ts_data *ts)
> input->id.product = 0x1001;
> input->id.version = ts->version;
>
> - if (input_register_device(input) != 0) {
> - input_free_device(input);
> + if (input_register_device(input) != 0)
> return NULL;
> - }
>
> return input;
> }
And this code has also already been fixed, so this patch can be dropped.
Regards,
Hans
prev parent reply other threads:[~2022-04-23 11:34 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
2022-04-23 11:34 ` Hans de Goede [this message]
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=c4f8bfef-1cb6-d7bb-dfe1-04b3d952738a@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).