Re: [PATCH v2] scsi: bsg: fix errno when scsi_bsg_register_queue fails

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

 



On Fri, Oct 22, 2021 at 09:02:01AM +0800, Jackie Liu wrote:
> From: Jackie Liu <liuyun01@xxxxxxxxxx>
> 
> When the value of error is printed, it will always be 0. Here, we should be
> print the correct error code when scsi_bsg_register_queue fails.
> 

The comment above the changed code says:

"
We're treating error on bsg register as non-fatal, so pretend nothing went wrong.
"

With this patch in place, "error" is returned to the caller, and the code
no longer pretends that nothing is wrong. Also, the message is a dev_info
message, not dev_err, suggesting that ignoring the error was indeed on
purpose. Assuming the comment is correct, this patch is plain wrong;
the message should have printed PTR_ERR(sdev->bsg_dev) instead and not set
the 'error' variable.

Guenter

> Fixes: ead09dd3aed5 ("scsi: bsg: Simplify device registration")
> Cc: Jens Axboe <axboe@xxxxxxxxx>
> Cc: Christoph Hellwig <hch@xxxxxx>
> Reviewed-by: Christoph Hellwig <hch@xxxxxx>
> Signed-off-by: Jackie Liu <liuyun01@xxxxxxxxxx>
> ---
>  v1->v2:
>  resend to linux-scsi mail list.
> 
>  drivers/scsi/scsi_sysfs.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
> index 86793259e541..d8789f6cda62 100644
> --- a/drivers/scsi/scsi_sysfs.c
> +++ b/drivers/scsi/scsi_sysfs.c
> @@ -1379,6 +1379,7 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev)
>  			 * We're treating error on bsg register as non-fatal, so
>  			 * pretend nothing went wrong.
>  			 */
> +			error = PTR_ERR(sdev->bsg_dev);
>  			sdev_printk(KERN_INFO, sdev,
>  				    "Failed to register bsg queue, errno=%d\n",
>  				    error);
> -- 
> 2.25.1
> 



[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