2021-06-09 12:35:35

by Can Guo

[permalink] [raw]
Subject: [PATCH] scsi: ufs: Fix a possible use before initialization case

In ufshcd_exec_dev_cmd(), if error happens before lrpb is initialized,
then we should bail out instead of letting trace record the error.

Fixes: a45f937110fa6 ("scsi: ufs: Optimize host lock on transfer requests send/compl paths")
Reported-by: kernel test robot <[email protected]>
Signed-off-by: Can Guo <[email protected]>

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index fe1b5f4..0d54ab7 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -2972,7 +2972,7 @@ static int ufshcd_exec_dev_cmd(struct ufs_hba *hba,

if (unlikely(test_bit(tag, &hba->outstanding_reqs))) {
err = -EBUSY;
- goto out;
+ goto out_put_tag;
}

init_completion(&wait);
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.


2021-06-09 17:09:34

by Stanley Chu

[permalink] [raw]
Subject: Re: [PATCH] scsi: ufs: Fix a possible use before initialization case

On Tue, 2021-06-08 at 20:36 -0700, Can Guo wrote:
> In ufshcd_exec_dev_cmd(), if error happens before lrpb is initialized,
> then we should bail out instead of letting trace record the error.
>
> Fixes: a45f937110fa6 ("scsi: ufs: Optimize host lock on transfer requests send/compl paths")
> Reported-by: kernel test robot <[email protected]>
> Signed-off-by: Can Guo <[email protected]>
>
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
> index fe1b5f4..0d54ab7 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -2972,7 +2972,7 @@ static int ufshcd_exec_dev_cmd(struct ufs_hba *hba,
>
> if (unlikely(test_bit(tag, &hba->outstanding_reqs))) {
> err = -EBUSY;
> - goto out;
> + goto out_put_tag;
> }
>
> init_completion(&wait);

Reviewed-by: Stanley Chu <[email protected]>