From: error27@gmail.com
To: oe-kbuild@lists.linux.dev, Yihang Li <liyihang9@huawei.com>,
jejb@linux.ibm.com, martin.petersen@oracle.com
Cc: lkp@intel.com, oe-kbuild-all@lists.linux.dev, bvanassche@acm.org,
john.garry@huawei.com, chenxiang66@hisilicon.com,
daejun7.park@samsung.com, damien.lemoal@opensource.wdc.com,
yanaijie@huawei.com, duoming@zju.edu.cn,
linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
prime.zeng@hisilicon.com, yangxingui@huawei.com,
linuxarm@huawei.com, liyihang9@huawei.com
Subject: Re: [PATCH] scsi: libsas: Check and update the link rate during discovery
Date: Thu, 3 Nov 2022 08:04:59 +0300 [thread overview]
Message-ID: <202211030845.FLT5UqWU-lkp@intel.com> (raw)
In-Reply-To: <20221102100555.3537275-1-liyihang9@huawei.com>
Hi Yihang,
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Yihang-Li/scsi-libsas-Check-and-update-the-link-rate-during-discovery/20221102-180734
base: https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next
patch link: https://lore.kernel.org/r/20221102100555.3537275-1-liyihang9%40huawei.com
patch subject: [PATCH] scsi: libsas: Check and update the link rate during discovery
config: m68k-randconfig-m041-20221102
compiler: m68k-linux-gcc (GCC) 12.1.0
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
New smatch warnings:
drivers/scsi/libsas/sas_expander.c:1962 sas_ex_update_linkrate() warn: iterator used outside loop: 'child'
Old smatch warnings:
drivers/scsi/libsas/sas_expander.c:253 sas_set_ex_phy() error: potential null dereference 'phy->phy'. (sas_phy_alloc returns null)
drivers/scsi/libsas/sas_expander.c:253 sas_set_ex_phy() error: we previously assumed 'phy->phy' could be null (see line 189)
drivers/scsi/libsas/sas_expander.c:1974 sas_ex_update_linkrate() warn: iterator used outside loop: 'child'
vim +/child +1962 drivers/scsi/libsas/sas_expander.c
39d64046e3dfc7 Yihang Li 2022-11-02 1947 static void sas_ex_update_linkrate(struct domain_device *parent)
39d64046e3dfc7 Yihang Li 2022-11-02 1948 {
39d64046e3dfc7 Yihang Li 2022-11-02 1949 struct expander_device *ex = &parent->ex_dev;
39d64046e3dfc7 Yihang Li 2022-11-02 1950 int i = 0, end = ex->num_phys;
39d64046e3dfc7 Yihang Li 2022-11-02 1951
39d64046e3dfc7 Yihang Li 2022-11-02 1952 for ( ; i < end; i++) {
39d64046e3dfc7 Yihang Li 2022-11-02 1953 struct ex_phy *ex_phy = &ex->ex_phy[i];
39d64046e3dfc7 Yihang Li 2022-11-02 1954 struct domain_device *child;
39d64046e3dfc7 Yihang Li 2022-11-02 1955
39d64046e3dfc7 Yihang Li 2022-11-02 1956 list_for_each_entry(child, &parent->ex_dev.children, siblings)
^^^^^
Imagine this loop exits without finding the correct child.
39d64046e3dfc7 Yihang Li 2022-11-02 1957 if (SAS_ADDR(child->sas_addr) ==
39d64046e3dfc7 Yihang Li 2022-11-02 1958 SAS_ADDR(ex_phy->attached_sas_addr))
39d64046e3dfc7 Yihang Li 2022-11-02 1959 break;
39d64046e3dfc7 Yihang Li 2022-11-02 1960
39d64046e3dfc7 Yihang Li 2022-11-02 1961 if (dev_is_sata(child)) {
^^^^^
That means "child" is not a valid pointer. Not sure why the warning is
only triggered on the line below instead of here.
39d64046e3dfc7 Yihang Li 2022-11-02 @1962 if (child->linkrate > parent->min_linkrate) {
39d64046e3dfc7 Yihang Li 2022-11-02 1963 struct sas_phy_linkrates rates = {
39d64046e3dfc7 Yihang Li 2022-11-02 1964 .maximum_linkrate = parent->min_linkrate,
39d64046e3dfc7 Yihang Li 2022-11-02 1965 .minimum_linkrate = parent->min_linkrate,
39d64046e3dfc7 Yihang Li 2022-11-02 1966 };
39d64046e3dfc7 Yihang Li 2022-11-02 1967
39d64046e3dfc7 Yihang Li 2022-11-02 1968 sas_smp_phy_control(parent, i,
39d64046e3dfc7 Yihang Li 2022-11-02 1969 PHY_FUNC_LINK_RESET, &rates);
39d64046e3dfc7 Yihang Li 2022-11-02 1970 ex_phy->phy_change_count = -1;
39d64046e3dfc7 Yihang Li 2022-11-02 1971 }
39d64046e3dfc7 Yihang Li 2022-11-02 1972 }
39d64046e3dfc7 Yihang Li 2022-11-02 1973
39d64046e3dfc7 Yihang Li 2022-11-02 1974 if (dev_is_expander(child->dev_type)) {
39d64046e3dfc7 Yihang Li 2022-11-02 1975 child->min_linkrate = min(parent->min_linkrate,
39d64046e3dfc7 Yihang Li 2022-11-02 1976 ex_phy->linkrate);
39d64046e3dfc7 Yihang Li 2022-11-02 1977 child->max_linkrate = max(parent->max_linkrate,
39d64046e3dfc7 Yihang Li 2022-11-02 1978 ex_phy->linkrate);
39d64046e3dfc7 Yihang Li 2022-11-02 1979 child->linkrate = min(ex_phy->linkrate,
39d64046e3dfc7 Yihang Li 2022-11-02 1980 child->max_linkrate);
39d64046e3dfc7 Yihang Li 2022-11-02 1981 ex_phy->phy_change_count = -1;
39d64046e3dfc7 Yihang Li 2022-11-02 1982 }
39d64046e3dfc7 Yihang Li 2022-11-02 1983 }
39d64046e3dfc7 Yihang Li 2022-11-02 1984 }
--
0-DAY CI Kernel Test Service
https://01.org/lkp
prev parent reply other threads:[~2022-11-03 5:05 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-02 10:05 [PATCH] scsi: libsas: Check and update the link rate during discovery Yihang Li
2022-11-02 11:55 ` John Garry
2022-11-07 11:52 ` Yihang Li
2022-11-07 12:44 ` [External] : " John Garry
2022-11-08 11:33 ` Yihang Li
2022-11-03 5:04 ` error27 [this message]
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=202211030845.FLT5UqWU-lkp@intel.com \
--to=error27@gmail.com \
--cc=bvanassche@acm.org \
--cc=chenxiang66@hisilicon.com \
--cc=daejun7.park@samsung.com \
--cc=damien.lemoal@opensource.wdc.com \
--cc=duoming@zju.edu.cn \
--cc=jejb@linux.ibm.com \
--cc=john.garry@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=liyihang9@huawei.com \
--cc=lkp@intel.com \
--cc=martin.petersen@oracle.com \
--cc=oe-kbuild-all@lists.linux.dev \
--cc=oe-kbuild@lists.linux.dev \
--cc=prime.zeng@hisilicon.com \
--cc=yanaijie@huawei.com \
--cc=yangxingui@huawei.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox