diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c index c6457bf..2e191f4 100644 --- a/drivers/scsi/hosts.c +++ b/drivers/scsi/hosts.c @@ -310,7 +310,7 @@ struct device_type scsi_host_type = { **/ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize) { - struct Scsi_Host *shost; + struct Scsi_Host *shost, *tmp_shost; gfp_t gfp_mask = GFP_KERNEL; int rval; @@ -332,7 +332,18 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize) mutex_init(&shost->scan_mutex); + /* + * Look if host_no is not been used somewhere else. Is is used to + * happen when scsi_host_next_hn overflows and goes back to 0. + */ + host_no_already_exists: shost->host_no = scsi_host_next_hn++; /* XXX(hch): still racy */ + if(!IS_ERR(tmp_shost = scsi_host_lookup(shost->host_no))) + { + scsi_host_put(tmp_shost); + goto host_no_already_exists; + } + shost->dma_channel = 0xff; /* These three are default values which can be overridden */