Re: should failed calls to device_register() always call put_device()?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, May 28, 2011 at 9:43 PM, Robert P. J. Day <rpjday@xxxxxxxxxxxxxx> wrote:
> On Sat, 28 May 2011, Belisko Marek wrote:
>
>> On Sat, May 28, 2011 at 6:29 PM, Robert P. J. Day <rpjday@xxxxxxxxxxxxxx> wrote:
>> >
>> > Âi agree that there should be a "put_device(&dev->dev);" statement
>> > as you show above. Âhowever, i still don't see how this can be
>> > just a stylistic improvement as you seem to suggest. Âbased on the
>> > warning from the kernel source file, it would seem that you *must*
>> > do a put_device() in that situation -- it's not optional.
>
>> Sure you're right. You can send a patch to fix this problem. Good
>> catch.
>
> Âi didn't want to submit anything until i verified what correct code
> should look like. Âand it's not like that's the only example -- others
> are trivially easy to find, like this in
> drivers/media/video/bt8xx/bttv-gpio.c (line 97):
>
> Âerr = device_register(&sub->dev);
> Âif (0 != err) {
> Â Â Â Â Â kfree(sub);
> Â Â Â Â Â return err;
> Â}
I'm little bit confused. If you look at device_add which is part of
device_register if
something in device_add failed it will always call put_device (in any
error case) so why
then is necessary to call it again when device_register return error?
As you said on some
places put_device is used on some not. Assume device_register in
normal conditions
don't fail so this code is not called anyway or?

>
> that would seem to be incorrect as well, no?
>
> rday
>
> --
>
> ========================================================================
> Robert P. J. Day                 Ottawa, Ontario, CANADA
> Â Â Â Â Â Â Â Â Â Â Â Âhttp://crashcourse.ca
>
> Twitter: Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â http://twitter.com/rpjday
> LinkedIn: Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â http://ca.linkedin.com/in/rpjday
> ========================================================================

regards,

marek

-- 
as simple and primitive as possible
-------------------------------------------------
Marek Belisko - OPEN-NANDRA
Freelance Developer

Ruska Nova Ves 219 | Presov, 08005 Slovak Republic
Tel: +421 915 052 184
skype: marekwhite
icq: 290551086
web: http://open-nandra.com

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux