Re: [SCSI] fix scsi_reap_target() device_del from atomic context

Matthew Wilcox
2005-12-23T12:15:35Z

On Thu, Dec 22, 2005 at 10:13:29PM -0800, Andrew Morton wrote:
> > + struct work_queue_wrapper *wqw = (struct work_queue_wrapper *)data;
> > + struct scsi_target *starget = wqw->starget;
> > + struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
> > + unsigned long flags;
> > +
> > + kfree(wqw);
> > +
> > + spin_lock_irqsave(shost->host_lock, flags);
> > +
> > + if (--starget->reap_ref == 0 && list_empty(&starget->devices)) {
> > + list_del_init(&starget->siblings);
> > + spin_unlock_irqrestore(shost->host_lock, flags);
> > + device_del(&starget->dev);
> > + transport_unregister_device(&starget->dev);
> > + put_device(&starget->dev);
> > + return;
> > +
> > + }
> > + spin_unlock_irqrestore(shost->host_lock, flags);
> > +
> > + return;
> > +}
>
> Given that this can run an arbitrary amount of time later on, how do we
> know that *shost is still live?

If there's still an starget, its parent shost must still be around, no?