提交 90e4ea18 编写于 作者: S Sreekanth Reddy 提交者: Zheng Zengkai

scsi: mpt3sas: Fix kernel panic during drive powercycle test

stable inclusion
from stable-v5.10.83
commit 2bf9c5a5039c8f4b037236aed505e6a25c1d5f7b
bugzilla: 185879 https://gitee.com/openeuler/kernel/issues/I4QUVG

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=2bf9c5a5039c8f4b037236aed505e6a25c1d5f7b

--------------------------------

[ Upstream commit 0ee4ba13 ]

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: f92363d1 ("[SCSI] mpt3sas: add new driver supporting 12GB SAS")
Signed-off-by: NSreekanth Reddy <sreekanth.reddy@broadcom.com>
Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 74c4955e
...@@ -3675,7 +3675,7 @@ _scsih_ublock_io_device(struct MPT3SAS_ADAPTER *ioc, u64 sas_address) ...@@ -3675,7 +3675,7 @@ _scsih_ublock_io_device(struct MPT3SAS_ADAPTER *ioc, u64 sas_address)
shost_for_each_device(sdev, ioc->shost) { shost_for_each_device(sdev, ioc->shost) {
sas_device_priv_data = sdev->hostdata; sas_device_priv_data = sdev->hostdata;
if (!sas_device_priv_data) if (!sas_device_priv_data || !sas_device_priv_data->sas_target)
continue; continue;
if (sas_device_priv_data->sas_target->sas_address if (sas_device_priv_data->sas_target->sas_address
!= sas_address) != sas_address)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册