kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* should failed calls to device_register() always call put_device()?
@ 2011-05-28 15:15 Robert P. J. Day
  2011-05-28 16:00 ` Belisko Marek
  0 siblings, 1 reply; 11+ messages in thread
From: Robert P. J. Day @ 2011-05-28 15:15 UTC (permalink / raw)
  To: kernelnewbies


  from drivers/base/core.c, we have the fairly unambiguous advice:

* NOTE: _Never_ directly free @dev after calling this function, even
* if it returned an error! Always use put_device() to give up the
* reference initialized in this function instead.
*/
int device_register(struct device *dev)
{
        device_initialize(dev);
        return device_add(dev);
}

  and yet, there appears to be driver code that does exactly that,
such as this snippet from drivers/w1/w1_int.c (line 86):

	... snip ...
        err = device_register(&dev->dev);
        if (err) {
                printk(KERN_ERR "Failed to register master device. err=%d\n", err);
                memset(dev, 0, sizeof(struct w1_master));
                kfree(dev);
                dev = NULL;
        }

        return dev;

  isn't the above doing just that -- directly freeing the dev
structure without first calling put_device()?  or am i misreading
something?

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2011-05-29 12:49 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-28 15:15 should failed calls to device_register() always call put_device()? Robert P. J. Day
2011-05-28 16:00 ` Belisko Marek
2011-05-28 16:29   ` Robert P. J. Day
2011-05-28 18:56     ` Belisko Marek
2011-05-28 19:43       ` Robert P. J. Day
2011-05-28 20:22         ` Belisko Marek
2011-05-28 22:01           ` Greg KH
2011-05-29 11:21             ` Robert P. J. Day
2011-05-29 11:49               ` Greg KH
2011-05-29 12:49                 ` Robert P. J. Day
2011-05-28 21:57   ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).