From: "Arend van Spriel" <arend@broadcom.com>
To: David Herrmann <dh.herrmann@googlemail.com>
Cc: Dan Carpenter <dan.carpenter@oracle.com>,
Julia Lawall <julia@diku.dk>, Jiri Kosina <jkosina@suse.cz>,
"kernel-janitors@vger.kernel.org"
<kernel-janitors@vger.kernel.org>,
"linux-input@vger.kernel.org" <linux-input@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 3/5] drivers/hid/hid-roccat.c: eliminate a null
Date: Mon, 31 Oct 2011 09:22:53 +0000 [thread overview]
Message-ID: <4EAE68ED.9070406@broadcom.com> (raw)
In-Reply-To: <CANq1E4QJoM+NYub9hfs3KnL1w212FK0MHo8ez2p1nyGmNVb-=A@mail.gmail.com>
On 10/29/2011 12:53 PM, David Herrmann wrote:
> On Sat, Oct 29, 2011 at 11:36 AM, Arend van Spriel <arend@broadcom.com> wrote:
>> On 10/29/2011 08:24 AM, Dan Carpenter wrote:
>>> On Sat, Oct 29, 2011 at 01:58:15AM +0200, Julia Lawall wrote:
>>>> diff --git a/drivers/hid/hid-roccat.c b/drivers/hid/hid-roccat.c
>>>> index 2596321..36a28b8 100644
>>>> --- a/drivers/hid/hid-roccat.c
>>>> +++ b/drivers/hid/hid-roccat.c
>>>> @@ -163,14 +163,15 @@ static int roccat_open(struct inode *inode, struct file *file)
>>>>
>>>> device = devices[minor];
>>>>
>>>> - mutex_lock(&device->readers_lock);
>>>> -
>>>> if (!device) {
>>>> pr_emerg("roccat device with minor %d doesn't exist\n", minor);
>>>> - error = -ENODEV;
>>>> - goto exit_err;
>>>> + kfree(reader);
>>>> + mutex_lock(&devices_lock);
>>>
>>> Typo. mutex_unlock() instead of mutex_lock().
>>
>> This is no typo, but simply wrong. Remove the mutex_lock() as we are
>> leaving the function here in error flow.
>
> No, this one is definitely needed. Its devices_lock, not
> device->readers_lock! And devices_lock is locked before so we need to
> unlock it if we return in this branch.
You are right. I missed that. As usual Dan's eye is sharper ;-)
Gr. AvS
WARNING: multiple messages have this Message-ID (diff)
From: "Arend van Spriel" <arend@broadcom.com>
To: David Herrmann <dh.herrmann@googlemail.com>
Cc: Dan Carpenter <dan.carpenter@oracle.com>,
Julia Lawall <julia@diku.dk>, Jiri Kosina <jkosina@suse.cz>,
"kernel-janitors@vger.kernel.org"
<kernel-janitors@vger.kernel.org>,
"linux-input@vger.kernel.org" <linux-input@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 3/5] drivers/hid/hid-roccat.c: eliminate a null pointer dereference
Date: Mon, 31 Oct 2011 10:22:53 +0100 [thread overview]
Message-ID: <4EAE68ED.9070406@broadcom.com> (raw)
In-Reply-To: <CANq1E4QJoM+NYub9hfs3KnL1w212FK0MHo8ez2p1nyGmNVb-=A@mail.gmail.com>
On 10/29/2011 12:53 PM, David Herrmann wrote:
> On Sat, Oct 29, 2011 at 11:36 AM, Arend van Spriel <arend@broadcom.com> wrote:
>> On 10/29/2011 08:24 AM, Dan Carpenter wrote:
>>> On Sat, Oct 29, 2011 at 01:58:15AM +0200, Julia Lawall wrote:
>>>> diff --git a/drivers/hid/hid-roccat.c b/drivers/hid/hid-roccat.c
>>>> index 2596321..36a28b8 100644
>>>> --- a/drivers/hid/hid-roccat.c
>>>> +++ b/drivers/hid/hid-roccat.c
>>>> @@ -163,14 +163,15 @@ static int roccat_open(struct inode *inode, struct file *file)
>>>>
>>>> device = devices[minor];
>>>>
>>>> - mutex_lock(&device->readers_lock);
>>>> -
>>>> if (!device) {
>>>> pr_emerg("roccat device with minor %d doesn't exist\n", minor);
>>>> - error = -ENODEV;
>>>> - goto exit_err;
>>>> + kfree(reader);
>>>> + mutex_lock(&devices_lock);
>>>
>>> Typo. mutex_unlock() instead of mutex_lock().
>>
>> This is no typo, but simply wrong. Remove the mutex_lock() as we are
>> leaving the function here in error flow.
>
> No, this one is definitely needed. Its devices_lock, not
> device->readers_lock! And devices_lock is locked before so we need to
> unlock it if we return in this branch.
You are right. I missed that. As usual Dan's eye is sharper ;-)
Gr. AvS
next prev parent reply other threads:[~2011-10-31 9:22 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-28 23:58 [PATCH 3/5] drivers/hid/hid-roccat.c: eliminate a null pointer dereference Julia Lawall
2011-10-28 23:58 ` Julia Lawall
2011-10-29 6:24 ` [PATCH 3/5] drivers/hid/hid-roccat.c: eliminate a null pointer Dan Carpenter
2011-10-29 6:24 ` [PATCH 3/5] drivers/hid/hid-roccat.c: eliminate a null pointer dereference Dan Carpenter
2011-10-29 9:36 ` [PATCH 3/5] drivers/hid/hid-roccat.c: eliminate a null Arend van Spriel
2011-10-29 9:36 ` [PATCH 3/5] drivers/hid/hid-roccat.c: eliminate a null pointer dereference Arend van Spriel
2011-10-29 10:53 ` David Herrmann
2011-10-29 10:53 ` David Herrmann
2011-10-29 10:53 ` David Herrmann
2011-10-29 12:11 ` [PATCH 3/5 v2] drivers/hid/hid-roccat.c: eliminate a null pointer Julia Lawall
2011-10-29 12:11 ` [PATCH 3/5 v2] drivers/hid/hid-roccat.c: eliminate a null pointer dereference Julia Lawall
2011-10-29 17:00 ` [PATCH 3/5 v2] drivers/hid/hid-roccat.c: eliminate a null pointer Jiri Kosina
2011-10-29 17:00 ` [PATCH 3/5 v2] drivers/hid/hid-roccat.c: eliminate a null pointer dereference Jiri Kosina
2011-10-29 18:18 ` [PATCH 3/5 v2] drivers/hid/hid-roccat.c: eliminate a null pointer Julia Lawall
2011-10-29 18:18 ` [PATCH 3/5 v2] drivers/hid/hid-roccat.c: eliminate a null pointer dereference Julia Lawall
2011-10-29 18:45 ` [PATCH 3/5 v3] drivers/hid/hid-roccat.c: eliminate a null pointer Julia Lawall
2011-10-29 18:45 ` [PATCH 3/5 v3] drivers/hid/hid-roccat.c: eliminate a null pointer dereference Julia Lawall
2011-11-01 14:14 ` [PATCH 3/5 v3] drivers/hid/hid-roccat.c: eliminate a null pointer Jiri Kosina
2011-11-01 14:14 ` [PATCH 3/5 v3] drivers/hid/hid-roccat.c: eliminate a null pointer dereference Jiri Kosina
2011-10-31 9:22 ` Arend van Spriel [this message]
2011-10-31 9:22 ` [PATCH 3/5] " Arend van Spriel
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=4EAE68ED.9070406@broadcom.com \
--to=arend@broadcom.com \
--cc=dan.carpenter@oracle.com \
--cc=dh.herrmann@googlemail.com \
--cc=jkosina@suse.cz \
--cc=julia@diku.dk \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.