提交 8e451839 编写于 作者: R Ranjan Kumar 提交者: Martin K. Petersen

scsi: mpi3mr: Bad drive in topology results kernel crash

When the SAS Transport Layer support is enabled and a device exposed to
the OS by the driver fails INQUIRY commands, the driver frees up the memory
allocated for an internal HBA port data structure. However, in some places,
the reference to the freed memory is not cleared. When the firmware sends
the Device Info change event for the same device again, the freed memory is
accessed and that leads to memory corruption and OS crash.
Signed-off-by: NRanjan Kumar <ranjan.kumar@broadcom.com>
Signed-off-by: NSreekanth Reddy <sreekanth.reddy@broadcom.com>
Link: https://lore.kernel.org/r/20230228140835.4075-7-ranjan.kumar@broadcom.comSigned-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
上级 4f297e85
...@@ -2358,15 +2358,16 @@ int mpi3mr_report_tgtdev_to_sas_transport(struct mpi3mr_ioc *mrioc, ...@@ -2358,15 +2358,16 @@ int mpi3mr_report_tgtdev_to_sas_transport(struct mpi3mr_ioc *mrioc,
tgtdev->host_exposed = 1; tgtdev->host_exposed = 1;
if (!mpi3mr_sas_port_add(mrioc, tgtdev->dev_handle, if (!mpi3mr_sas_port_add(mrioc, tgtdev->dev_handle,
sas_address_parent, hba_port)) { sas_address_parent, hba_port)) {
tgtdev->host_exposed = 0;
retval = -1; retval = -1;
} else if ((!tgtdev->starget)) { } else if ((!tgtdev->starget) && (!mrioc->is_driver_loading)) {
if (!mrioc->is_driver_loading)
mpi3mr_sas_port_remove(mrioc, sas_address, mpi3mr_sas_port_remove(mrioc, sas_address,
sas_address_parent, hba_port); sas_address_parent, hba_port);
tgtdev->host_exposed = 0;
retval = -1; retval = -1;
} }
if (retval) {
tgtdev->dev_spec.sas_sata_inf.hba_port = NULL;
tgtdev->host_exposed = 0;
}
return retval; return retval;
} }
...@@ -2395,6 +2396,7 @@ void mpi3mr_remove_tgtdev_from_sas_transport(struct mpi3mr_ioc *mrioc, ...@@ -2395,6 +2396,7 @@ void mpi3mr_remove_tgtdev_from_sas_transport(struct mpi3mr_ioc *mrioc,
mpi3mr_sas_port_remove(mrioc, sas_address, sas_address_parent, mpi3mr_sas_port_remove(mrioc, sas_address, sas_address_parent,
hba_port); hba_port);
tgtdev->host_exposed = 0; tgtdev->host_exposed = 0;
tgtdev->dev_spec.sas_sata_inf.hba_port = NULL;
} }
/** /**
...@@ -2451,7 +2453,7 @@ static u8 mpi3mr_get_port_id_by_rphy(struct mpi3mr_ioc *mrioc, struct sas_rphy * ...@@ -2451,7 +2453,7 @@ static u8 mpi3mr_get_port_id_by_rphy(struct mpi3mr_ioc *mrioc, struct sas_rphy *
tgtdev = __mpi3mr_get_tgtdev_by_addr_and_rphy(mrioc, tgtdev = __mpi3mr_get_tgtdev_by_addr_and_rphy(mrioc,
rphy->identify.sas_address, rphy); rphy->identify.sas_address, rphy);
if (tgtdev) { if (tgtdev && tgtdev->dev_spec.sas_sata_inf.hba_port) {
port_id = port_id =
tgtdev->dev_spec.sas_sata_inf.hba_port->port_id; tgtdev->dev_spec.sas_sata_inf.hba_port->port_id;
mpi3mr_tgtdev_put(tgtdev); mpi3mr_tgtdev_put(tgtdev);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册