On Tue, 2016-12-13 at 15:50 -0600, Benjamin Marzinski wrote: > On Tue, Dec 13, 2016 at 04:27:09PM -0200, Mauricio Faria de Oliveira > wrote: > When you call alloc_path_with_pathinfo(), it already grabs the second > reference before calling pathinfo. When it exits without pp_ptr being > set, it frees that extra reference in free_path(). But this whole > time, > we are still servicing the uevent, and that originl reference is > always > held, so we don't ever need to worry about the udevice getting > deleted > out from under us. I don't see any possible danger in removing the > udev_device_ref/unref calls from your code. They don't hurt anything, > but grabbing references when we don't need them just confuses other > people who are trying reading the code, and makes the purpose of the > references harder to understand. As someone who has just recently started reading the multipath-tools code in depth, I tend to disagree. Someone reading the function including the udev_device_ref()/unref() calls would see that the device references are handled correctly in the function itself, without having to know or having to track down how the device references are created and dropped in other parts of the code. Moreover, if the global ref handling was ever to be changed in the future, this function would still be "safe". If the udev_device_ref/unref calls are removed, at least a comment explaining why they aren't needed would help new readers of the code. Regards Martin -- Dr. Martin Wilck <mwilck@xxxxxxxx>, Tel. +49 (0)911 74053 2107 SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton HRB 21284 (AG Nürnberg) -- dm-devel mailing list dm-devel@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/dm-devel