]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
scsi: ufs-bsg: complete ufs-bsg job only if no error
authorBean Huo <beanhuo@micron.com>
Sun, 23 Jun 2019 17:38:56 +0000 (17:38 +0000)
committerMartin K. Petersen <martin.petersen@oracle.com>
Thu, 27 Jun 2019 02:42:24 +0000 (22:42 -0400)
In the case of UPIU/DME request execution failed in UFS device,
ufs_bsg_request() will complete the failed bsg job by calling
bsg_job_done(). Meanwhile, it returns this error status to blk-mq layer,
then triggers blk-mq completing this request again, this will cause the
following panic.

Call trace:
ll_sc___cmpxchg_case_acq_32+0x4/0x20
complete+0x28/0x70
blk_end_sync_rq+0x24/0x30
blk_mq_end_request+0xb8/0x118
bsg_job_put+0x4c/0x58
bsg_complete+0x20/0x30
blk_done_softirq+0xb4/0xe8
do_softirq+0x154/0x3f0
run_ksoftirqd+0x4c/0x68
smpboot_thread_fn+0x22c/0x268
kthread+0x130/0x138
ret_from_fork+0x10/0x1c
Code: f84107fe d65f03c0 d503201f f9800011 (885ffc10)
---[ end trace d92825bff6326e66 ]---
Kernel panic - not syncing: Fatal exception in interrupt

This patch is to fix this issue. The solution is to complete the ufs-bsg
job only if no error happened.

[mkp: commit description tweak]

Fixes: df032bf27a41 (scsi: ufs: Add a bsg endpoint that supports UPIUs)
Signed-off-by: Bean Huo <beanhuo@micron.com>
Reviewed-by: Avri Altman <Avri.Altman@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/ufs/ufs_bsg.c

index f420d6f8d84c70e2ac29e781b6939a639d662503..a9344eb4e047f1e73c28212024c1e8dcefb19228 100644 (file)
@@ -149,7 +149,9 @@ static int ufs_bsg_request(struct bsg_job *job)
 out:
        bsg_reply->result = ret;
        job->reply_len = sizeof(struct ufs_bsg_reply);
-       bsg_job_done(job, ret, bsg_reply->reply_payload_rcv_len);
+       /* complete the job here only if no error */
+       if (ret == 0)
+               bsg_job_done(job, ret, bsg_reply->reply_payload_rcv_len);
 
        return ret;
 }