Skip to content

Commit df96dbe

Browse files
ahunter6gregkh
authored andcommitted
scsi: ufs: core: Fix invalid probe error return value
commit a2b32bc1d9e359a9f90d0de6af16699facb10935 upstream. After DME Link Startup, the error return value is set to the MIPI UniPro GenericErrorCode which can be 0 (SUCCESS) or 1 (FAILURE). Upon failure during driver probe, the error code 1 is propagated back to the driver probe function which must return a negative value to indicate an error, but 1 is not negative, so the probe is considered to be successful even though it failed. Subsequently, removing the driver results in an oops because it is not in a valid state. This happens because none of the callers of ufshcd_init() expect a non-negative error code. Fix the return value and documentation to match actual usage. Fixes: 69f5eb7 ("scsi: ufs: core: Move the ufshcd_device_init(hba, true) call") Cc: [email protected] Signed-off-by: Adrian Hunter <[email protected]> Reviewed-by: Bart Van Assche <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Martin K. Petersen <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent dbd6c27 commit df96dbe

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

drivers/ufs/core/ufshcd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10638,7 +10638,7 @@ static int ufshcd_add_scsi_host(struct ufs_hba *hba)
1063810638
* @mmio_base: base register address
1063910639
* @irq: Interrupt line of device
1064010640
*
10641-
* Return: 0 on success, non-zero value on failure.
10641+
* Return: 0 on success; < 0 on failure.
1064210642
*/
1064310643
int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
1064410644
{
@@ -10879,7 +10879,7 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
1087910879
hba->is_irq_enabled = false;
1088010880
ufshcd_hba_exit(hba);
1088110881
out_error:
10882-
return err;
10882+
return err > 0 ? -EIO : err;
1088310883
}
1088410884
EXPORT_SYMBOL_GPL(ufshcd_init);
1088510885

0 commit comments

Comments
 (0)