On 6/27/24 1:51 AM, 김경률 wrote:
If host tries to remove ufshcd driver from a ufs device, it would cause a kernel panic if ufshcd_async_scan fails during ufshcd_probe_hba before adding a scsi host with scsi_add_host and MCQ is enabled since scsi host has been defered after MCQ configuration introduced by Commit 0cab4023ec7b ("scsi: ufs: core: Defer adding host to SCSI if MCQ is supported"). To guarantee that scsi host is removed only if it's been added, set the scsi_host_added flag to true after adding a scsi host and check whether it's set or not before removing the scsi host.
Reviewed-by: Bart Van Assche <bvanassche@xxxxxxx>