[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <202211030845.FLT5UqWU-lkp@intel.com>
Date: Thu, 3 Nov 2022 08:04:59 +0300
From: error27@...il.com
To: oe-kbuild@...ts.linux.dev, Yihang Li <liyihang9@...wei.com>,
jejb@...ux.ibm.com, martin.petersen@...cle.com
Cc: lkp@...el.com, oe-kbuild-all@...ts.linux.dev, bvanassche@....org,
john.garry@...wei.com, chenxiang66@...ilicon.com,
daejun7.park@...sung.com, damien.lemoal@...nsource.wdc.com,
yanaijie@...wei.com, duoming@....edu.cn,
linux-scsi@...r.kernel.org, linux-kernel@...r.kernel.org,
prime.zeng@...ilicon.com, yangxingui@...wei.com,
linuxarm@...wei.com, liyihang9@...wei.com
Subject: Re: [PATCH] scsi: libsas: Check and update the link rate during
discovery
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@...el.com>
| Reported-by: Dan Carpenter <error27@...il.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
Powered by blists - more mailing lists