SCSI core uses scsi_host_set_state() to control the host's state machine; this function returns 0 on success and -EINVAL on failure to change host's state. The only place where the result of scsi_host_set_state() is ignored is in scsi_add_host_with_dma() -- that blithely continues initializing the SCSI host even if the host's state couldn't be set to SHOST_RUNNING... I guess the logic behind this is that scsi_add_host_with_dma() call is always preceded by scsi_host_alloc() call which leaves the host's state machine in the SHOST_CREATED state which is a valid previous state for SHOST_RUNNING. I think we'd better check result of scsi_host_set_state() always -- better safe than sorry! Found by Linux Verification Center (linuxtesting.org) with the Svace static analysis tool. Signed-off-by: Sergey Shtylyov <s.shtylyov@xxxxxx> --- The patch is against the 'for-next' branch of Martin Petersen's 'scsi.git' repo. drivers/scsi/hosts.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) Index: scsi/drivers/scsi/hosts.c =================================================================== --- scsi.orig/drivers/scsi/hosts.c +++ scsi/drivers/scsi/hosts.c @@ -272,7 +272,10 @@ int scsi_add_host_with_dma(struct Scsi_H if (error) goto out_disable_runtime_pm; - scsi_host_set_state(shost, SHOST_RUNNING); + error = scsi_host_set_state(shost, SHOST_RUNNING); + if (error) + goto out_disable_runtime_pm; + get_device(shost->shost_gendev.parent); device_enable_async_suspend(&shost->shost_dev);