On Wed, 2018-04-11 at 16:11 +0200, Hannes Reinecke wrote: > On Mon, 9 Apr 2018 23:23:51 -0700 > Anatoliy Glagolev <glago...@gmail.com> wrote: > > > Description: > > SCSI mid-layer may hold references to Scsi_Host structs when > > the owning module has already unloaded. Scsi_Host release path > > touches scsi_host_template struct that is usually allocated > > in the unloaded module's memory. That results in a crash. > > To work around the problem, this change implements > > scsi_host_template_release API to be called at driver unload > > path to make sure all Scsi_Host structs are gone before > > releasing scsi_host_template memory. > > > > --- > > drivers/scsi/hosts.c | 2 ++ > > drivers/scsi/qla2xxx/qla_os.c | 2 ++ > > drivers/scsi/scsi_priv.h | 1 + > > drivers/scsi/scsi_proc.c | 64 > > +++++++++++++++++++++++++++++++++++++++---- > > include/scsi/scsi_host.h | 17 ++++++++++++ 5 files changed, 80 > > insertions(+), 6 deletions(-) > > > > Whee, that is ugly.
And what's the actual problem it's solving? It looks to be something in qla2xxx module removal? > Any particular reason why we can't do refcounting here? We can ... the template is module data and any reference to the dev or the host will increment the module reference. We could even have a dummy template reference that only incremented the module refcount. However, knowing what to do involves knowing what the problem is and how it is triggered. James