The following patch is against lk 2.5.26. The prior implementation called scsi_unregister(host) from idescsi_cleanup(), removing the Scsi_Host instance from the scsi_hostlist. Later when scsi_unregister_host(&template) was called from exit_idescsi_module() but since the Scsi_Host instance had already been removed no matches for the template were found and the device instances remained. The patch moves the scsi_unregister_host(&template) to idescsi_cleanup(). Since scsi_unregister_host() invokes scsi_unregister() this part of the cleanup also occurs normally.