summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSreekanth Reddy <sreekanth.reddy@broadcom.com>2021-11-17 16:19:09 +0530
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-12-08 08:45:03 +0100
commit58ef2c7a6de13721865d84b80eecf56d6cba0937 (patch)
treeb35d08868fc4e6262cd69ea4e7ec319288b232d7
parent7afc6600ba3e2190a798c28898f132025d303d5a (diff)
downloadlinux-stable-58ef2c7a6de13721865d84b80eecf56d6cba0937.tar.gz
linux-stable-58ef2c7a6de13721865d84b80eecf56d6cba0937.tar.bz2
linux-stable-58ef2c7a6de13721865d84b80eecf56d6cba0937.zip
scsi: mpt3sas: Fix kernel panic during drive powercycle test
[ Upstream commit 0ee4ba13e09c9d9c1cb6abb59da8295d9952328b ] While looping over shost's sdev list it is possible that one of the drives is getting removed and its sas_target object is freed but its sdev object remains intact. Consequently, a kernel panic can occur while the driver is trying to access the sas_address field of sas_target object without also checking the sas_target object for NULL. Link: https://lore.kernel.org/r/20211117104909.2069-1-sreekanth.reddy@broadcom.com Fixes: f92363d12359 ("[SCSI] mpt3sas: add new driver supporting 12GB SAS") Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--drivers/scsi/mpt3sas/mpt3sas_scsih.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
index 58876b8a2e9f..8063b97bf2e9 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
@@ -2927,7 +2927,7 @@ _scsih_ublock_io_device(struct MPT3SAS_ADAPTER *ioc, u64 sas_address)
shost_for_each_device(sdev, ioc->shost) {
sas_device_priv_data = sdev->hostdata;
- if (!sas_device_priv_data)
+ if (!sas_device_priv_data || !sas_device_priv_data->sas_target)
continue;
if (sas_device_priv_data->sas_target->sas_address
!= sas_address)