2017-12-20 23:53 GMT+08:00 Cornelia Huck <cohuck@xxxxxxxxxx>: > On Wed, 20 Dec 2017 12:26:25 +0800 > weiping zhang <zwp10758@xxxxxxxxx> wrote: > > [you used a different mail address in your From: than in your s-o-b:; > same for the other patches] > >> In order to make caller do a simple cleanup, we split device_register >> into device_initialize and device_add. device_initialize always sucess, > > s/success/succeeds/ > >> the caller can always use put_device when fail to register virtio_device > > "so the caller can always use put_device when register_virtio_device > failed," > >> no matter fail at ida_simple_get or at device_add. > > "no matter whether it failed..." > >> + * >> + * If an error occurs, the caller must use put_device, instead of kfree, because >> + * device_initialize and device_add will increase @dev->dev's reference count. > > That's not correct: It's not because of device_add increasing the > reference count (it releases it again on failure), but because another > code path may have obtained a reference. > > What about: > > "On error, the caller must call put_device on &@dev->dev (and not > kfree), as another code path may have obtained a reference to @dev." > It's good to understand, further more dev->name may has a bit mem leak. anyway, I'll correct all comments at V5. Thanks very much. >> + * >> + * Returns: 0 on suceess, -error on failure >> + */ >> int register_virtio_device(struct virtio_device *dev) _______________________________________________ Virtualization mailing list Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx https://lists.linuxfoundation.org/mailman/listinfo/virtualization