Re: [PATCH] scsi core: fix uninitialized variable error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 5 Feb 2006, Matthew Wilcox wrote:

> Seems to me it'd be much easier just  to initialise sdev to
> ERR_PTR(-ENODEV) at the top of the function.  That way, __scsi_add_device
> doesn't need to know what the return codes from scsi_probe_and_add_lun
> mean.  Something like this (untested):

> @@ -1278,12 +1277,8 @@ struct scsi_device *__scsi_add_device(st
>  
>  	get_device(&starget->dev);
>  	mutex_lock(&shost->scan_mutex);
> -	if (scsi_host_scan_allowed(shost)) {
> -		res = scsi_probe_and_add_lun(starget, lun, NULL, &sdev, 1,
> -					     hostdata);
> -		if (res != SCSI_SCAN_LUN_PRESENT)
> -			sdev = ERR_PTR(-ENODEV);
> -	}
> +	if (scsi_host_scan_allowed(shost))
> +		scsi_probe_and_add_lun(starget, lun, NULL, &sdev, 1, hostdata);
>  	mutex_unlock(&shost->scan_mutex);
>  	scsi_target_reap(starget);
>  	put_device(&starget->dev);

This assumes that scsi_probe_and_add_lun doesn't assign anything to the 
&sdev pointer if it returns anything other than SCSI_SCAN_LUN_PRESENT.  
Since that assumption is true for the current code, this version of the 
patch will work as well as mine.

Alan Stern

-
: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux