summaryrefslogtreecommitdiff
path: root/drivers/scsi/cxlflash
diff options
context:
space:
mode:
authorMatthew R. Ochs <mrochs@linux.vnet.ibm.com>2016-09-02 23:40:41 +0300
committerMartin K. Petersen <martin.petersen@oracle.com>2016-09-14 19:47:42 +0300
commitc4a11827b760ef8dcda26b5731d072b1d8fb7c81 (patch)
tree6bda9df01ddca909ce2dd4f49e46e69c579062d2 /drivers/scsi/cxlflash
parentf80132613d576e7e705344d0c33f3b5e65d9e16a (diff)
downloadlinux-c4a11827b760ef8dcda26b5731d072b1d8fb7c81.tar.xz
scsi: cxlflash: Fix context reference tracking on detach
Commit 888baf069f49 ("scsi: cxlflash: Add kref to context") introduced a kref to the context. In particular, the detach routine was updated to use the kref services for managing the removal and destruction of a context. As part of this change, the tracking mechanism internal to the detach handler was refactored. This introduced a bug that can cause the tracking state to be lost. This can lead to a situation where exclusive access to a context is prematurely [and unknowingly] relinquished for the executing thread. To remedy, only update the tracking state when the kref operation indicates the context was removed. Fixes: 888baf069f49 ("scsi: cxlflash: Add kref to context") Signed-off-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com> Acked-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/scsi/cxlflash')
-rw-r--r--drivers/scsi/cxlflash/superpipe.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/scsi/cxlflash/superpipe.c b/drivers/scsi/cxlflash/superpipe.c
index c91fe6fe8d08..9636970d9611 100644
--- a/drivers/scsi/cxlflash/superpipe.c
+++ b/drivers/scsi/cxlflash/superpipe.c
@@ -912,7 +912,8 @@ static int _cxlflash_disk_detach(struct scsi_device *sdev,
* Release the context reference and the sdev reference that
* bound this LUN to the context.
*/
- put_ctx = !kref_put(&ctxi->kref, remove_context);
+ if (kref_put(&ctxi->kref, remove_context))
+ put_ctx = false;
scsi_device_put(sdev);
out:
if (put_ctx)