Right now, lkrg_register_net() does not return a status, and on unload we call lkrg_deregister_net() unconditionally. If we keep that, then lkrg_deregister_net() should be made smarter not to shut down things that were never initialized. With the current code, the easiest way to do this is to wrap the entirety of lkrg_deregister_net() code in if (kmsg_file). It already has that check, but only for (not) calling filp_close(). We already similarly check kmsg_file in lkrg_queue_net(), which the rest of LKRG also calls unconditionally.
Meanwhile, our calling of unregister_console() appears to be harmless, only producing a superfluous kernel message about that.
Right now,
lkrg_register_net()
does not return a status, and on unload we calllkrg_deregister_net()
unconditionally. If we keep that, thenlkrg_deregister_net()
should be made smarter not to shut down things that were never initialized. With the current code, the easiest way to do this is to wrap the entirety oflkrg_deregister_net()
code inif (kmsg_file)
. It already has that check, but only for (not) callingfilp_close()
. We already similarly checkkmsg_file
inlkrg_queue_net()
, which the rest of LKRG also calls unconditionally.Meanwhile, our calling of
unregister_console()
appears to be harmless, only producing a superfluous kernel message about that.