Add a safety check for freeing kernel modules.