If device_register() fails, call put_device() to drop the device reference. Also, call device_unregister() if device_create_file() fails.
See also once more: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Docu...
You propose to complete the exception handling for two cases. Is there a need to indicate such a detail in the summary phrase accordingly?
Regards, Markus