mbox series

[0/2] Fix the error path in ufshcd_async_scan()

Message ID 20231218225229.2542156-1-bvanassche@acm.org
Headers show
Series Fix the error path in ufshcd_async_scan() | expand

Message

Bart Van Assche Dec. 18, 2023, 10:52 p.m. UTC
Hi Martin,

This patch series fixes a kernel crash triggered by the error path of
ufshcd_async_scan(). Please consider this patch series for the next merge
window.

Thanks,

Bart.

Bart Van Assche (2):
  scsi: ufs: Simplify power management during async scan
  scsi: ufs: Remove the ufshcd_hba_exit() call from ufshcd_async_scan()

 drivers/ufs/core/ufshcd.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

Comments

Can Guo Dec. 19, 2023, 5:04 a.m. UTC | #1
On 12/19/2023 6:52 AM, Bart Van Assche wrote:
> ufshcd_init() calls pm_runtime_get_sync() before it calls
> async_schedule(). ufshcd_async_scan() calls pm_runtime_put_sync()
> directly or indirectly from ufshcd_add_lus(). Simplify
> ufshcd_async_scan() by always calling pm_runtime_put_sync() from
> ufshcd_async_scan().
> 
> Cc: stable@vger.kernel.org
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>   drivers/ufs/core/ufshcd.c | 7 +++----
>   1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> index d6ae5d17892c..0ad8bde39cd1 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -8711,7 +8711,6 @@ static int ufshcd_add_lus(struct ufs_hba *hba)
>   
>   	ufs_bsg_probe(hba);
>   	scsi_scan_host(hba->host);
> -	pm_runtime_put_sync(hba->dev);
>   
>   out:
>   	return ret;
> @@ -8980,15 +8979,15 @@ static void ufshcd_async_scan(void *data, async_cookie_t cookie)
>   
>   	/* Probe and add UFS logical units  */
>   	ret = ufshcd_add_lus(hba);
> +
>   out:
> +	pm_runtime_put_sync(hba->dev);
>   	/*
>   	 * If we failed to initialize the device or the device is not
>   	 * present, turn off the power/clocks etc.
>   	 */
> -	if (ret) {
> -		pm_runtime_put_sync(hba->dev);
> +	if (ret)
>   		ufshcd_hba_exit(hba);
> -	}
>   }
>   
>   static enum scsi_timeout_action ufshcd_eh_timed_out(struct scsi_cmnd *scmd)

Reviewed-by: Can Guo <quic_cang@quicinc.com>
Bart Van Assche Dec. 20, 2023, 4:36 p.m. UTC | #2
On 12/20/23 06:42, Manivannan Sadhasivam wrote:
> On Mon, Dec 18, 2023 at 02:52:14PM -0800, Bart Van Assche wrote:
>> ufshcd_init() calls pm_runtime_get_sync() before it calls
>> async_schedule(). ufshcd_async_scan() calls pm_runtime_put_sync()
>> directly or indirectly from ufshcd_add_lus(). Simplify
>> ufshcd_async_scan() by always calling pm_runtime_put_sync() from
>> ufshcd_async_scan().
>>
>> Cc: stable@vger.kernel.org
> 
> No fixes tag?

There is no Fixes: tag because this patch does not change the behavior of
the UFS driver. The Cc: stable tag is present because the next patch in this
series has a Fixes: tag and depends on this patch.

Thanks,

Bart.