> Free the nvmem structure only after we are done using it. This information can be reasonable. > This patch just moves the put_device() down a bit to avoid the > use after free. I suggest to reconsider such a change because a device reference count should eventually be decremented before decrementing the reference count for the module which is managed by this programming interface. Are you also looking for better software documentation for such an use case? Regards, Markus