From: Jonathan Corbet <corbet@lwn.net>
To: Kangjie Lu <kjlu@umn.edu>
Cc: pakki001@umn.edu, Jiri Kosina <jikos@kernel.org>,
Benjamin Tissoires <benjamin.tissoires@redhat.com>,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] hid: logitech: check the return value of create_singlethread_workqueue
Date: Tue, 12 Mar 2019 10:02:33 -0600 [thread overview]
Message-ID: <20190312100233.106098c8@lwn.net> (raw)
In-Reply-To: <20190312061628.13869-1-kjlu@umn.edu>
On Tue, 12 Mar 2019 01:16:28 -0500
Kangjie Lu <kjlu@umn.edu> wrote:
> create_singlethread_workqueue may fail and return NULL. The fix
> checks if it is NULL to avoid NULL pointer dereference.
> Also, the fix moves the call of create_singlethread_workqueue
> earlier to avoid resource-release issues.
>
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
So I don't know this code at all, but...
> drivers/hid/hid-logitech-hidpp.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c
> index 15ed6177a7a3..1b7c336cae6d 100644
> --- a/drivers/hid/hid-logitech-hidpp.c
> +++ b/drivers/hid/hid-logitech-hidpp.c
> @@ -2106,6 +2106,12 @@ static int hidpp_ff_init(struct hidpp_device *hidpp, u8 feature_index)
> data = kzalloc(sizeof(*data), GFP_KERNEL);
> if (!data)
> return -ENOMEM;
> +
> + /* init the hardware command queue */
> + data->wq = create_singlethread_workqueue("hidpp-ff-sendqueue");
> + if (!data->wq)
> + return -ENOMEM;
It's clear just from the diff that this return will leak 'data'. You also
break the error handling just below:
> data->effect_ids = kcalloc(num_slots, sizeof(int), GFP_KERNEL);
> if (!data->effect_ids) {
> kfree(data);
It's also worth asking: how are you testing these error path changes?
Thanks,
jon
next prev parent reply other threads:[~2019-03-12 16:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-09 4:43 [PATCH] hid: logitech: check the return value of create_singlethread_workqueue Kangjie Lu
2019-03-11 15:08 ` Benjamin Tissoires
2019-03-12 6:16 ` [PATCH v2] " Kangjie Lu
2019-03-12 16:02 ` Jonathan Corbet [this message]
2019-03-14 5:24 ` [PATCH v3] " Kangjie Lu
2019-03-19 10:48 ` Jiri Kosina
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=20190312100233.106098c8@lwn.net \
--to=corbet@lwn.net \
--cc=benjamin.tissoires@redhat.com \
--cc=jikos@kernel.org \
--cc=kjlu@umn.edu \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pakki001@umn.edu \
/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).