Skip to content

Commit a2b32bc

Browse files
ahunter6martinkpetersen
authored andcommitted
scsi: ufs: core: Fix invalid probe error return value
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: stable@vger.kernel.org Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Reviewed-by: Bart Van Assche <bvanassche@acm.org> Link: https://patch.msgid.link/20251024085918.31825-5-adrian.hunter@intel.com Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent d968e99 commit a2b32bc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/ufs/core/ufshcd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10656,7 +10656,7 @@ static int ufshcd_add_scsi_host(struct ufs_hba *hba)
1065610656
* @mmio_base: base register address
1065710657
* @irq: Interrupt line of device
1065810658
*
10659-
* Return: 0 on success, non-zero value on failure.
10659+
* Return: 0 on success; < 0 on failure.
1066010660
*/
1066110661
int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
1066210662
{
@@ -10897,7 +10897,7 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
1089710897
hba->is_irq_enabled = false;
1089810898
ufshcd_hba_exit(hba);
1089910899
out_error:
10900-
return err;
10900+
return err > 0 ? -EIO : err;
1090110901
}
1090210902
EXPORT_SYMBOL_GPL(ufshcd_init);
1090310903

0 commit comments

Comments
 (0)