On Mon, 12 Feb 2024 at 14:04, Dan Williams <dan.j.williams@xxxxxxxxx> wrote: > > This works because the internals of virtio_fs_cleanup_dax(), "kill_dax() > and put_dax()", know how to handle a NULL @dax_dev. It is still early > days with the "cleanup" helpers, but I wonder if anyone else cares that > the DEFINE_FREE() above does not check for NULL? Well, the main reason for DEFINE_FREE() to check for NULL is not correctness, but code generation. See the comment about kfree() in <linux/cleanup.h>: * NOTE: the DEFINE_FREE()'s @free expression includes a NULL test even though * kfree() is fine to be called with a NULL value. This is on purpose. This way * the compiler sees the end of our alloc_obj() function as [...] with the full explanation there. Now, whether the code wants to actually use the cleanup() helpers for a single use-case is debatable. But yes, if it does, I suspect it should use !IS_ERR_OR_NULL(ptr). Linus