All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: chenxiang66@hisilicon.com
Cc: linux-scsi@vger.kernel.org
Subject: [bug report] scsi: hisi_sas: Fix some issues related to asd_sas_port->phy_list
Date: Mon, 10 Jan 2022 15:54:28 +0300	[thread overview]
Message-ID: <20220110125428.GA5230@kili> (raw)

Hello Xiang Chen,

The patch 29e2bac87421: "scsi: hisi_sas: Fix some issues related to
asd_sas_port->phy_list" from Dec 20, 2021, leads to the following
Smatch static checker warning:

	drivers/scsi/hisi_sas/hisi_sas_main.c:1536 hisi_sas_send_ata_reset_each_phy()
	error: potentially dereferencing uninitialized 'sas_phy'.

drivers/scsi/hisi_sas/hisi_sas_main.c
    1519 static void hisi_sas_send_ata_reset_each_phy(struct hisi_hba *hisi_hba,
    1520                                              struct asd_sas_port *sas_port,
    1521                                              struct domain_device *device)
    1522 {
    1523         struct hisi_sas_tmf_task tmf_task = { .force_phy = 1 };
    1524         struct ata_port *ap = device->sata_dev.ap;
    1525         struct device *dev = hisi_hba->dev;
    1526         int s = sizeof(struct host_to_dev_fis);
    1527         int rc = TMF_RESP_FUNC_FAILED;
    1528         struct asd_sas_phy *sas_phy;
    1529         struct ata_link *link;
    1530         u8 fis[20] = {0};
    1531         u32 state;
    1532         int i;
    1533 
    1534         state = hisi_hba->hw->get_phys_state(hisi_hba);
    1535         for (i = 0; i < hisi_hba->n_phy; i++) {
--> 1536                 if (!(state & BIT(sas_phy->id)))
                                           ^^^^^^^
This is no longer initialized anywhere.

    1537                         continue;
    1538                 if (!(sas_port->phy_mask & BIT(i)))
    1539                         continue;
    1540 
    1541                 ata_for_each_link(link, ap, EDGE) {
    1542                         int pmp = sata_srst_pmp(link);
    1543 
    1544                         tmf_task.phy_id = i;
    1545                         hisi_sas_fill_ata_reset_cmd(link->device, 1, pmp, fis);
    1546                         rc = hisi_sas_exec_internal_tmf_task(device, fis, s,
    1547                                                              &tmf_task);
    1548                         if (rc != TMF_RESP_FUNC_COMPLETE) {
    1549                                 dev_err(dev, "phy%d ata reset failed rc=%d\n",
    1550                                         i, rc);
    1551                                 break;
    1552                         }
    1553                 }
    1554         }
    1555 }

regards,
dan carpenter

             reply	other threads:[~2022-01-10 12:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-10 12:54 Dan Carpenter [this message]
2022-01-10 16:35 ` [bug report] scsi: hisi_sas: Fix some issues related to asd_sas_port->phy_list John Garry

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220110125428.GA5230@kili \
    --to=dan.carpenter@oracle.com \
    --cc=chenxiang66@hisilicon.com \
    --cc=linux-scsi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.