Thread (11 messages) 11 messages, 3 authors, 2011-05-29

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

From: Robert P. J. Day <hidden>
Date: 2011-05-28 19:43:13

On Sat, 28 May 2011, Belisko Marek wrote:
On Sat, May 28, 2011 at 6:29 PM, Robert P. J. Day [off-list ref] wrote:
quoted
?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;
  }

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
========================================================================
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help