]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
scsi: hisi_sas: Fix out of bound at debug_I_T_nexus_reset()
authorLuo Jiaxing <luojiaxing@huawei.com>
Mon, 5 Aug 2019 13:48:03 +0000 (21:48 +0800)
committerMarcelo Henrique Cerri <marcelo.cerri@canonical.com>
Fri, 17 Jan 2020 17:23:11 +0000 (14:23 -0300)
BugLink: https://launchpad.net/bugs/1853992
Fix a possible out-of-bounds access in hisi_sas_debug_I_T_nexus_reset().

Signed-off-by: Luo Jiaxing <luojiaxing@huawei.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 445ee2de112a18419aeae72fdae4221cd90f2948)
Signed-off-by: Ike Panhc <ike.pan@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Acked-by: Marcelo Henrique Cerri <marcelo.cerri@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
drivers/scsi/hisi_sas/hisi_sas_main.c

index be6877931ac43ac4032d02331a0e097dd8c7db69..48a61d77dce48b7fec4f89de1527ffa62de10422 100644 (file)
@@ -1596,12 +1596,13 @@ static int hisi_sas_debug_I_T_nexus_reset(struct domain_device *device)
                        (device->tproto & SAS_PROTOCOL_STP)) ? 0 : 1;
        struct hisi_hba *hisi_hba = dev_to_hisi_hba(device);
        struct sas_ha_struct *sas_ha = &hisi_hba->sha;
-       struct asd_sas_phy *sas_phy = sas_ha->sas_phy[local_phy->number];
-       struct hisi_sas_phy *phy = container_of(sas_phy,
-                       struct hisi_sas_phy, sas_phy);
        DECLARE_COMPLETION_ONSTACK(phyreset);
 
        if (scsi_is_sas_phy_local(local_phy)) {
+               struct asd_sas_phy *sas_phy =
+                       sas_ha->sas_phy[local_phy->number];
+               struct hisi_sas_phy *phy =
+                       container_of(sas_phy, struct hisi_sas_phy, sas_phy);
                phy->in_reset = 1;
                phy->reset_completion = &phyreset;
        }
@@ -1610,6 +1611,10 @@ static int hisi_sas_debug_I_T_nexus_reset(struct domain_device *device)
        sas_put_local_phy(local_phy);
 
        if (scsi_is_sas_phy_local(local_phy)) {
+               struct asd_sas_phy *sas_phy =
+                       sas_ha->sas_phy[local_phy->number];
+               struct hisi_sas_phy *phy =
+                       container_of(sas_phy, struct hisi_sas_phy, sas_phy);
                int ret = wait_for_completion_timeout(&phyreset, 2 * HZ);
                unsigned long flags;