On Fri, Dec 10, 2021 at 4:18 AM Dan Carpenter <dan.carpenter(a)oracle.com> wrote:
tree:
https://chromium.googlesource.com/chromiumos/third_party/kernel chromeos-5.10
head: 3eae3ffb66ef2c07a94f385c4160c405cc3a490b
commit: 7fc5fdfd89dcb4030def0f07c3a015509dcca1c6 [94/100] BACKPORT: FROMLIST:
iommu/mediatek: Contain MM IOMMU flow with the MM TYPE
config: riscv-randconfig-m031-20211210
(
https://download.01.org/0day-ci/archive/20211210/202112101915.YoEDCiBh-lk...
)
compiler: riscv64-linux-gcc (GCC) 11.2.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp(a)intel.com>
Reported-by: Dan Carpenter <dan.carpenter(a)oracle.com>
smatch warnings:
drivers/iommu/mtk_iommu.c:865 mtk_iommu_mm_dts_parse() error: uninitialized symbol
'larbnode'.
drivers/iommu/mtk_iommu.c:878 mtk_iommu_mm_dts_parse() warn: passing zero to
'PTR_ERR'
vim +/larbnode +865 drivers/iommu/mtk_iommu.c
7fc5fdfd89dcb4 Yong Wu 2021-09-23 824 static int mtk_iommu_mm_dts_parse(struct device
*dev,
7fc5fdfd89dcb4 Yong Wu 2021-09-23 825 struct
component_match **match,
7fc5fdfd89dcb4 Yong Wu 2021-09-23 826 struct
mtk_iommu_data *data)
7fc5fdfd89dcb4 Yong Wu 2021-09-23 827 {
7fc5fdfd89dcb4 Yong Wu 2021-09-23 828 struct platform_device *plarbdev;
7fc5fdfd89dcb4 Yong Wu 2021-09-23 829 struct device_link *link;
7fc5fdfd89dcb4 Yong Wu 2021-09-23 830 struct device_node *larbnode,
*smicomm_node;
7fc5fdfd89dcb4 Yong Wu 2021-09-23 831 int i, larb_nr, ret;
7fc5fdfd89dcb4 Yong Wu 2021-09-23 832
7fc5fdfd89dcb4 Yong Wu 2021-09-23 833 larb_nr =
of_count_phandle_with_args(dev->of_node, "mediatek,larbs", NULL);
Can of_count_phandle_with_args() return 0? That's what the uninitialized
variable warning is complaining about. No idea if it's really possible.
With non-NULL argument, definitely yes. With NULL argument, it boils down to
of_get_property() being able to return a size of 0 or not. Various
code in the kernel
suggests that this is the case. Here is an example from
build_device_resources():
preg = of_get_property(op->dev.of_node, bus->addr_prop_name, &num_reg);
if (!preg || num_reg == 0)
return;
A test confirms that of_count_phandle_with_args() called on boolean
properties does indeed return 0. Other code explicitly ensures that
the return value is > 0, so the code below should probably also check
for that.
Note that this code is (in other form) in the upstream kernel, so it
also needs to be be fixed there.
7fc5fdfd89dcb4 Yong Wu 2021-09-23 834 if (larb_nr < 0)
7fc5fdfd89dcb4 Yong Wu 2021-09-23 835 return larb_nr;
7fc5fdfd89dcb4 Yong Wu 2021-09-23 836
7fc5fdfd89dcb4 Yong Wu 2021-09-23 837 for (i = 0; i < larb_nr; i++) {
7fc5fdfd89dcb4 Yong Wu 2021-09-23 838 u32 id;
7fc5fdfd89dcb4 Yong Wu 2021-09-23 839
7fc5fdfd89dcb4 Yong Wu 2021-09-23 840 larbnode =
of_parse_phandle(dev->of_node, "mediatek,larbs", i);
7fc5fdfd89dcb4 Yong Wu 2021-09-23 841 if (!larbnode)
7fc5fdfd89dcb4 Yong Wu 2021-09-23 842 return -EINVAL;
7fc5fdfd89dcb4 Yong Wu 2021-09-23 843
7fc5fdfd89dcb4 Yong Wu 2021-09-23 844 if
(!of_device_is_available(larbnode)) {
7fc5fdfd89dcb4 Yong Wu 2021-09-23 845 of_node_put(larbnode);
7fc5fdfd89dcb4 Yong Wu 2021-09-23 846 continue;
7fc5fdfd89dcb4 Yong Wu 2021-09-23 847 }
7fc5fdfd89dcb4 Yong Wu 2021-09-23 848
7fc5fdfd89dcb4 Yong Wu 2021-09-23 849 ret =
of_property_read_u32(larbnode, "mediatek,larb-id", &id);
7fc5fdfd89dcb4 Yong Wu 2021-09-23 850 if (ret)/* The id is consecutive
if there is no this property */
7fc5fdfd89dcb4 Yong Wu 2021-09-23 851 id = i;
7fc5fdfd89dcb4 Yong Wu 2021-09-23 852
7fc5fdfd89dcb4 Yong Wu 2021-09-23 853 plarbdev =
of_find_device_by_node(larbnode);
7fc5fdfd89dcb4 Yong Wu 2021-09-23 854 if (!plarbdev ||
!plarbdev->dev.driver) {
7fc5fdfd89dcb4 Yong Wu 2021-09-23 855 of_node_put(larbnode);
7fc5fdfd89dcb4 Yong Wu 2021-09-23 856 return -EPROBE_DEFER;
7fc5fdfd89dcb4 Yong Wu 2021-09-23 857 }
7fc5fdfd89dcb4 Yong Wu 2021-09-23 858 data->larb_imu[id].dev =
&plarbdev->dev;
7fc5fdfd89dcb4 Yong Wu 2021-09-23 859
7fc5fdfd89dcb4 Yong Wu 2021-09-23 860 component_match_add_release(dev,
match, release_of,
7fc5fdfd89dcb4 Yong Wu 2021-09-23 861
compare_of, larbnode);
7fc5fdfd89dcb4 Yong Wu 2021-09-23 862 }
7fc5fdfd89dcb4 Yong Wu 2021-09-23 863
7fc5fdfd89dcb4 Yong Wu 2021-09-23 864 /* Get smi-common dev from the last larb.
*/
7fc5fdfd89dcb4 Yong Wu 2021-09-23 @865 smicomm_node = of_parse_phandle(larbnode,
"mediatek,smi", 0);
^^^^^^^^
7fc5fdfd89dcb4 Yong Wu 2021-09-23 866 if (!smicomm_node)
7fc5fdfd89dcb4 Yong Wu 2021-09-23 867 return -EINVAL;
7fc5fdfd89dcb4 Yong Wu 2021-09-23 868
7fc5fdfd89dcb4 Yong Wu 2021-09-23 869 plarbdev =
of_find_device_by_node(smicomm_node);
7fc5fdfd89dcb4 Yong Wu 2021-09-23 870 of_node_put(smicomm_node);
7fc5fdfd89dcb4 Yong Wu 2021-09-23 871 data->smicomm_dev =
&plarbdev->dev;
7fc5fdfd89dcb4 Yong Wu 2021-09-23 872
7fc5fdfd89dcb4 Yong Wu 2021-09-23 873 link =
device_link_add(data->smicomm_dev, dev,
7fc5fdfd89dcb4 Yong Wu 2021-09-23 874 DL_FLAG_STATELESS
| DL_FLAG_PM_RUNTIME);
7fc5fdfd89dcb4 Yong Wu 2021-09-23 875
7fc5fdfd89dcb4 Yong Wu 2021-09-23 876 if (!link) {
7fc5fdfd89dcb4 Yong Wu 2021-09-23 877 dev_err(dev, "Unable link
%s.\n", dev_name(data->smicomm_dev));
7fc5fdfd89dcb4 Yong Wu 2021-09-23 @878 return PTR_ERR(link);
^^^^^^^^^^^^^^^^^^^^^
This is equivalent to return 0;
Correct. For reference, see commit a92a90ac62d32 ("iommu/mediatek: Fix
error code in probe()") from one Dan Carpenter in the upstream kernel
;-). For whatever reason that error handling was removed in commit
7fc5fdfd89dcb4.
Guenter
> 7fc5fdfd89dcb4 Yong Wu 2021-09-23 879 }
> 7fc5fdfd89dcb4 Yong Wu 2021-09-23 880 return 0;
> 7fc5fdfd89dcb4 Yong Wu 2021-09-23 881 }
>
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
>
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
> _______________________________________________
> kbuild mailing list -- kbuild(a)lists.01.org
> To unsubscribe send an email to kbuild-leave(a)lists.01.org
>