From: Jiri Kosina <jikos@kernel.org>
To: Dinghao Liu <dinghao.liu@zju.edu.cn>
Cc: kjlu@umn.edu, Benjamin Tissoires <benjamin.tissoires@redhat.com>,
Alexandrov Stansilav <neko@nya.ai>,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] HID: elan: Fix memleak in elan_input_configured
Date: Mon, 31 Aug 2020 09:48:19 +0200 (CEST) [thread overview]
Message-ID: <nycvar.YFH.7.76.2008310947070.27422@cbobk.fhfr.pm> (raw)
In-Reply-To: <20200824072400.9612-1-dinghao.liu@zju.edu.cn>
On Mon, 24 Aug 2020, Dinghao Liu wrote:
> When input_mt_init_slots() fails, input should be
> freed to prevent memleak.
>
> Fixes: 9a6a4193d65b8 ("HID: Add driver for USB ELAN Touchpad")
> Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
> ---
> drivers/hid/hid-elan.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/hid/hid-elan.c b/drivers/hid/hid-elan.c
> index 45c4f888b7c4..858442004258 100644
> --- a/drivers/hid/hid-elan.c
> +++ b/drivers/hid/hid-elan.c
> @@ -188,6 +188,7 @@ static int elan_input_configured(struct hid_device *hdev, struct hid_input *hi)
> ret = input_mt_init_slots(input, ELAN_MAX_FINGERS, INPUT_MT_POINTER);
> if (ret) {
> hid_err(hdev, "Failed to init elan MT slots: %d\n", ret);
> + input_free_device(input);
> return ret;
Good catch, but apparently it's not the only memleak there --
input_mt_init_slots() allocates the input_mt slots and friends, so we need
input_mt_destroy_slots() there as well.
Could you please add this to your patch too, while you are at fixing this
error codepath anyway, and resubmit?
Thanks!
--
Jiri Kosina
SUSE Labs
next prev parent reply other threads:[~2020-08-31 7:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-24 7:23 [PATCH] HID: elan: Fix memleak in elan_input_configured Dinghao Liu
2020-08-31 7:48 ` Jiri Kosina [this message]
2020-08-31 7:56 ` dinghao.liu
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=nycvar.YFH.7.76.2008310947070.27422@cbobk.fhfr.pm \
--to=jikos@kernel.org \
--cc=benjamin.tissoires@redhat.com \
--cc=dinghao.liu@zju.edu.cn \
--cc=kjlu@umn.edu \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=neko@nya.ai \
/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).