[PATCH 5.4 19/21] scsi: ufs: Unlock on a couple error paths
From: Greg Kroah-Hartman
Date: Wed May 05 2021 - 08:05:25 EST
From: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
commit bb14dd1564c90d333f51e69dd6fc880b8233ce11 upstream.
We introduced a few new error paths, but we can't return directly, we first
have to unlock "hba->clk_scaling_lock" first.
Fixes: a276c19e3e98 ("scsi: ufs: Avoid busy-waiting by eliminating tag conflicts")
Link: https://lore.kernel.org/r/20191213104828.7i64cpoof26rc4fw@kili.mountain
Reviewed-by: Bart Van Assche <bvanassche@xxxxxxx>
Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
Signed-off-by: Martin K. Petersen <martin.petersen@xxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
drivers/scsi/ufs/ufshcd.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -2639,8 +2639,10 @@ static int ufshcd_exec_dev_cmd(struct uf
* the maximum wait time is bounded by SCSI request timeout.
*/
req = blk_get_request(q, REQ_OP_DRV_OUT, 0);
- if (IS_ERR(req))
- return PTR_ERR(req);
+ if (IS_ERR(req)) {
+ err = PTR_ERR(req);
+ goto out_unlock;
+ }
tag = req->tag;
WARN_ON_ONCE(!ufshcd_valid_tag(hba, tag));
@@ -2668,6 +2670,7 @@ static int ufshcd_exec_dev_cmd(struct uf
out_put_tag:
blk_put_request(req);
+out_unlock:
up_read(&hba->clk_scaling_lock);
return err;
}
@@ -5842,8 +5845,10 @@ static int ufshcd_issue_devman_upiu_cmd(
down_read(&hba->clk_scaling_lock);
req = blk_get_request(q, REQ_OP_DRV_OUT, 0);
- if (IS_ERR(req))
- return PTR_ERR(req);
+ if (IS_ERR(req)) {
+ err = PTR_ERR(req);
+ goto out_unlock;
+ }
tag = req->tag;
WARN_ON_ONCE(!ufshcd_valid_tag(hba, tag));
@@ -5920,6 +5925,7 @@ static int ufshcd_issue_devman_upiu_cmd(
}
blk_put_request(req);
+out_unlock:
up_read(&hba->clk_scaling_lock);
return err;
}