lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 24 Jul 2013 17:43:03 +0200
From:	Benjamin Tissoires <benjamin.tissoires@...il.com>
To:	Andy Shevchenko <andy.shevchenko@...il.com>
Cc:	Benjamin Tissoires <benjamin.tissoires@...hat.com>,
	Henrik Rydberg <rydberg@...omail.se>,
	Jiri Kosina <jkosina@...e.cz>,
	Stephane Chatty <chatty@...c.fr>,
	linux-input <linux-input@...r.kernel.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 1/2] HID: trivial devm conversion for special hid drivers

On Wed, Jul 24, 2013 at 5:37 PM, Andy Shevchenko
<andy.shevchenko@...il.com> wrote:
> On Wed, Jul 24, 2013 at 6:29 PM, Benjamin Tissoires
> <benjamin.tissoires@...hat.com> wrote:
>> It is safe to use devres allocation within the hid subsystem:
>> - the devres release is called _after_ the call to .remove(), meaning
>>   that no freed pointers will exists while removing the device
>> - if a .probe() fails, devres releases all the allocated ressources
>>   before going to the next driver: there will not be ghost ressources
>>   attached to a hid device if several drivers are probed.
>>
>> Given that, we can clean up a little some of the HID drivers. These ones
>> are trivial:
>> - there is only one kzalloc in the driver
>> - the .remove() callback contains only one kfree on top of hid_hw_stop()
>> - the error path in the probe is easy enough to be manually checked
>
> Thanks for the patch! I'm sorry I didn't find time to do what I was
> talking about last time.

no problems :)

>
> Few comments below.
>
>> --- a/drivers/hid/hid-a4tech.c
>> +++ b/drivers/hid/hid-a4tech.c
>
>> @@ -104,29 +103,16 @@ static int a4_probe(struct hid_device *hdev, const struct hid_device_id *id)
>>         ret = hid_parse(hdev);
>>         if (ret) {
>>                 hid_err(hdev, "parse failed\n");
>> -               goto err_free;
>> +               return ret;
>>         }
>>
>>         ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
>> -       if (ret) {
>> +       if (ret)
>>                 hid_err(hdev, "hw start failed\n");
>> -               goto err_free;
>> -       }
>>
>> -       return 0;
>
> Isn't it better to leave explicit return 0? I think it would be fool
> proof in case someone wants to add anything in the middle.

yes, it might be. At least that's what I've done with the other drivers...

>
>> -err_free:
>> -       kfree(a4);
>>         return ret;
>>  }
>
>> -static void a4_remove(struct hid_device *hdev)
>> -{
>> -       struct a4tech_sc *a4 = hid_get_drvdata(hdev);
>> -
>> -       hid_hw_stop(hdev);
>
> Is it safe to remove this call?
> This question is the same for all patched drivers.

It is. Once this call is removed, we use the in-core remove path,
which calls hid_hw_stop().

Thanks for the review.

Cheers,
Benjamin
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ