]> git.baikalelectronics.ru Git - kernel.git/commit
mpt3sas: Refcount sas_device objects and fix unsafe list usage
authorSreekanth Reddy <sreekanth.reddy@avagotech.com>
Wed, 11 Nov 2015 12:00:30 +0000 (17:30 +0530)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 11 Nov 2015 23:57:38 +0000 (18:57 -0500)
commit22602ac46f56703bfbdfba0db84452fa6c74ca65
tree1600d3477752a7f90e2e8812a80eef0511393d4d
parentecef6c20d72edfd3d9365154b32793978be86e27
mpt3sas: Refcount sas_device objects and fix unsafe list usage

sas_device objects can be referenced concurrently throughout the driver.
We need a way to make sure threads can't delete them out from under each
other. This patch adds the refcount and refactors the code to use it.

Additionally, we cannot iterate over the sas_device_list without holding
the lock or we risk corrupting random memory if items are added or
deleted as we iterate. This patch refactors _scsih_probe_sas() to use
the sas_device_list in a safe way.

This patch is ported from the following mpt2sas driver commit
960bc4af1bdd ("mpt2sas: Refcount sas_device objects and fix unsafe list
usage").

Signed-off-by: Sreekanth Reddy <Sreekanth.Reddy@avagotech.com>
Acked-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/mpt3sas/mpt3sas_base.h
drivers/scsi/mpt3sas/mpt3sas_scsih.c
drivers/scsi/mpt3sas/mpt3sas_transport.c