2010-08-08 14:30:50

by Daniel J Blueman

[permalink] [raw]
Subject: [2.6.35 patch] add missing unlock_kernel calls...

Hi Roger,

Here is a fix for 2.6.36-rc1:

Ensure the BKL is dropped along all paths.

Signed-off-by: Daniel J Blueman <[email protected]>

diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
index c24d2fa..53263e7 100644
--- a/drivers/hid/usbhid/hiddev.c
+++ b/drivers/hid/usbhid/hiddev.c
@@ -271,16 +271,18 @@ static int hiddev_open(struct inode *inode,
struct file *file)
lock_kernel();
i = iminor(inode) - HIDDEV_MINOR_BASE;

- if (i >= HIDDEV_MINORS || i < 0 || !hiddev_table[i])
+ if (i >= HIDDEV_MINORS || i < 0 || !hiddev_table[i]) {
+ unlock_kernel();
return -ENODEV;
+ }

- if (!(list = kzalloc(sizeof(struct hiddev_list), GFP_KERNEL)))
+ if (!(list = kzalloc(sizeof(struct hiddev_list), GFP_KERNEL))) {
+ unlock_kernel();
return -ENOMEM;
- mutex_init(&list->thread_lock);
+ }

+ mutex_init(&list->thread_lock);
list->hiddev = hiddev_table[i];
-
-
file->private_data = list;

/*
--
Daniel J Blueman


2010-08-08 14:58:27

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [2.6.35 patch] add missing unlock_kernel calls...

On Sunday 08 August 2010, Daniel J Blueman wrote:
> Hi Roger,
>
> Here is a fix for 2.6.36-rc1:
>
> Ensure the BKL is dropped along all paths.
>
> Signed-off-by: Daniel J Blueman <[email protected]>
>
> diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
> index c24d2fa..53263e7 100644
> --- a/drivers/hid/usbhid/hiddev.c
> +++ b/drivers/hid/usbhid/hiddev.c
> @@ -271,16 +271,18 @@ static int hiddev_open(struct inode *inode,
> struct file *file)
> lock_kernel();
> i = iminor(inode) - HIDDEV_MINOR_BASE;
>
> - if (i >= HIDDEV_MINORS || i < 0 || !hiddev_table[i])
> + if (i >= HIDDEV_MINORS || i < 0 || !hiddev_table[i]) {
> + unlock_kernel();
> return -ENODEV;
> + }
>
> - if (!(list = kzalloc(sizeof(struct hiddev_list), GFP_KERNEL)))
> + if (!(list = kzalloc(sizeof(struct hiddev_list), GFP_KERNEL))) {
> + unlock_kernel();
> return -ENOMEM;
> - mutex_init(&list->thread_lock);
> + }
>
> + mutex_init(&list->thread_lock);
> list->hiddev = hiddev_table[i];
> -
> -
> file->private_data = list;
>
> /*

This should no longer be needed, since the BKL is not taken
in this code any more.

Arnd

2010-08-08 15:01:31

by Daniel J Blueman

[permalink] [raw]
Subject: Re: [2.6.35 patch] add missing unlock_kernel calls...

On 8 August 2010 15:58, Arnd Bergmann <[email protected]> wrote:
> On Sunday 08 August 2010, Daniel J Blueman wrote:
>> Hi Roger,
>>
>> Here is a fix for 2.6.36-rc1:
>>
>> Ensure the BKL is dropped along all paths.
>>
>> Signed-off-by: Daniel J Blueman <[email protected]>
>>
>> diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
>> index c24d2fa..53263e7 100644
>> --- a/drivers/hid/usbhid/hiddev.c
>> +++ b/drivers/hid/usbhid/hiddev.c
>> @@ -271,16 +271,18 @@ static int hiddev_open(struct inode *inode,
>> struct file *file)
>> ? ? ? lock_kernel();
>> ? ? ? i = iminor(inode) - HIDDEV_MINOR_BASE;
>>
>> - ? ? if (i >= HIDDEV_MINORS || i < 0 || !hiddev_table[i])
>> + ? ? if (i >= HIDDEV_MINORS || i < 0 || !hiddev_table[i]) {
>> + ? ? ? ? ? ? unlock_kernel();
>> ? ? ? ? ? ? ? return -ENODEV;
>> + ? ? }
>>
>> - ? ? if (!(list = kzalloc(sizeof(struct hiddev_list), GFP_KERNEL)))
>> + ? ? if (!(list = kzalloc(sizeof(struct hiddev_list), GFP_KERNEL))) {
>> + ? ? ? ? ? ? unlock_kernel();
>> ? ? ? ? ? ? ? return -ENOMEM;
>> - ? ? mutex_init(&list->thread_lock);
>> + ? ? }
>>
>> + ? ? mutex_init(&list->thread_lock);
>> ? ? ? list->hiddev = hiddev_table[i];
>> -
>> -
>> ? ? ? file->private_data = list;
>>
>> ? ? ? /*
>
> This should no longer be needed, since the BKL is not taken
> in this code any more.

All the more better then, thanks to your BKL removal patches.

Thanks,
Daniel
--
Daniel J Blueman