lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <d4052784-255e-8000-8e8e-e5e29108f39a@intel.com>
Date:   Mon, 9 May 2022 13:49:48 +0800
From:   kernel test robot <yujie.liu@...el.com>
To:     Andrew Lunn <andrew@...n.ch>
CC:     <llvm@...ts.linux.dev>, <kbuild-all@...ts.01.org>,
        "Linux Kernel Mailing List" <linux-kernel@...r.kernel.org>
Subject: [lunn:dsa-ci 22/47] drivers/net/phy/mdio_bus.c:710:9: warning: The
 expression is an uninitialized value. The computed value will also be garbage
 [clang-analyzer-core.uninitialized.Assign]

tree:   https://github.com/lunn/linux.git dsa-ci
head:   1149273e5c97f04e2255421372a8a30c75c0b842
commit: e582444c20a13a52eabf1d982d1f7e96344be2a8 [22/47] net: mdiobus: Rework scanning of bus ready for quirks
config: i386-randconfig-c001 (https://download.01.org/0day-ci/archive/20220504/202205042049.SwDh4zxv-lkp@intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 09325d36061e42b495d1f4c7e933e260eac260ed)
reproduce (this is a W=1 build):
         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
         chmod +x ~/bin/make.cross
         # https://github.com/lunn/linux/commit/e582444c20a13a52eabf1d982d1f7e96344be2a8
         git remote add lunn https://github.com/lunn/linux.git
         git fetch --no-tags lunn dsa-ci
         git checkout e582444c20a13a52eabf1d982d1f7e96344be2a8
         # save the config file
         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=i386 clang-analyzer

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <yujie.liu@...el.com>


clang-analyzer warnings: (new ones prefixed by >>)

 >> drivers/net/phy/mdio_bus.c:710:9: warning: The expression is an uninitialized value. The computed value will also be garbage [clang-analyzer-core.uninitialized.Assign]
            while (--i >= 0) {
                   ^ ~
    drivers/net/phy/mdio_bus.c:621:6: note: 'i' declared without an initial value
            int i, err;
                ^

vim +710 drivers/net/phy/mdio_bus.c

4ed8df519849887 Andrew Lunn            2022-04-20  603
b3df0da886ffdb3 Randy Dunlap           2007-03-06  604  /**
59f069789c98678 Russell King           2015-09-25  605   * __mdiobus_register - bring up all the PHYs on a given bus and attach them to bus
b3df0da886ffdb3 Randy Dunlap           2007-03-06  606   * @bus: target mii_bus
59f069789c98678 Russell King           2015-09-25  607   * @owner: module containing bus accessor functions
e13934563db0470 Andy Fleming           2005-08-24  608   *
b3df0da886ffdb3 Randy Dunlap           2007-03-06  609   * Description: Called by a bus driver to bring up all the PHYs
59f069789c98678 Russell King           2015-09-25  610   *   on a given bus, and attach them to the bus. Drivers should use
59f069789c98678 Russell King           2015-09-25  611   *   mdiobus_register() rather than __mdiobus_register() unless they
f89df3f381f1e12 Andrew Lunn            2016-01-06  612   *   need to pass a specific owner module. MDIO devices which are not
fec76125baf7390 Peng Li                2021-03-30  613   *   PHYs will not be brought up by this function. They are expected
f89df3f381f1e12 Andrew Lunn            2016-01-06  614   *   to be explicitly listed in DT and instantiated by of_mdiobus_register().
b3df0da886ffdb3 Randy Dunlap           2007-03-06  615   *
b3df0da886ffdb3 Randy Dunlap           2007-03-06  616   * Returns 0 on success or < 0 on error.
e13934563db0470 Andy Fleming           2005-08-24  617   */
3e3aaf649416988 Russell King           2015-09-24  618  int __mdiobus_register(struct mii_bus *bus, struct module *owner)
e13934563db0470 Andy Fleming           2005-08-24  619  {
711fdba37a3dd7e Andrew Lunn            2016-01-06  620  	struct mdio_device *mdiodev;
161c8d2f50109b4 Krzysztof Halasa       2008-12-25 @621  	int i, err;
69226896ad636b9 Roger Quadros          2017-04-21  622  	struct gpio_desc *gpiod;
e13934563db0470 Andy Fleming           2005-08-24  623
effd7e805c90de8 Andrew Lunn            2022-04-02  624  	if (NULL == bus || NULL == bus->name)
effd7e805c90de8 Andrew Lunn            2022-04-02  625  		return -EINVAL;
effd7e805c90de8 Andrew Lunn            2022-04-02  626
effd7e805c90de8 Andrew Lunn            2022-04-02  627  	if (!bus->read != !bus->write)
effd7e805c90de8 Andrew Lunn            2022-04-02  628  		return -EINVAL;
effd7e805c90de8 Andrew Lunn            2022-04-02  629
effd7e805c90de8 Andrew Lunn            2022-04-02  630  	if (!bus->read_c45 != !bus->write_c45)
effd7e805c90de8 Andrew Lunn            2022-04-02  631  		return -EINVAL;
effd7e805c90de8 Andrew Lunn            2022-04-02  632
effd7e805c90de8 Andrew Lunn            2022-04-02  633  	if (!bus->read && !bus->read_c45)
e13934563db0470 Andy Fleming           2005-08-24  634  		return -EINVAL;
e13934563db0470 Andy Fleming           2005-08-24  635
04f41c68f18886a Saravana Kannan        2021-09-15  636  	if (bus->parent && bus->parent->of_node)
04f41c68f18886a Saravana Kannan        2021-09-15  637  		bus->parent->of_node->fwnode.flags |=
04f41c68f18886a Saravana Kannan        2021-09-15  638  					FWNODE_FLAG_NEEDS_CHILD_BOUND_ON_ADD;
04f41c68f18886a Saravana Kannan        2021-09-15  639
867ae8a7993b26f Florian Fainelli       2021-11-17  640  	WARN(bus->state != MDIOBUS_ALLOCATED &&
867ae8a7993b26f Florian Fainelli       2021-11-17  641  	     bus->state != MDIOBUS_UNREGISTERED,
867ae8a7993b26f Florian Fainelli       2021-11-17  642  	     "%s: not in ALLOCATED or UNREGISTERED state\n", bus->id);
46abc02175b3c24 Lennert Buytenhek      2008-10-08  643
3e3aaf649416988 Russell King           2015-09-24  644  	bus->owner = owner;
46abc02175b3c24 Lennert Buytenhek      2008-10-08  645  	bus->dev.parent = bus->parent;
46abc02175b3c24 Lennert Buytenhek      2008-10-08  646  	bus->dev.class = &mdio_bus_class;
46abc02175b3c24 Lennert Buytenhek      2008-10-08  647  	bus->dev.groups = NULL;
036b66879addb28 Stephen Hemminger      2009-02-26  648  	dev_set_name(&bus->dev, "%s", bus->id);
46abc02175b3c24 Lennert Buytenhek      2008-10-08  649
ca6e11c337daf79 Pavel Skripkin         2021-09-30  650  	/* We need to set state to MDIOBUS_UNREGISTERED to correctly release
ca6e11c337daf79 Pavel Skripkin         2021-09-30  651  	 * the device in mdiobus_free()
ca6e11c337daf79 Pavel Skripkin         2021-09-30  652  	 *
ca6e11c337daf79 Pavel Skripkin         2021-09-30  653  	 * State will be updated later in this function in case of success
ca6e11c337daf79 Pavel Skripkin         2021-09-30  654  	 */
ca6e11c337daf79 Pavel Skripkin         2021-09-30  655  	bus->state = MDIOBUS_UNREGISTERED;
ca6e11c337daf79 Pavel Skripkin         2021-09-30  656
46abc02175b3c24 Lennert Buytenhek      2008-10-08  657  	err = device_register(&bus->dev);
46abc02175b3c24 Lennert Buytenhek      2008-10-08  658  	if (err) {
8d242488ce4627d Joe Perches            2012-06-09  659  		pr_err("mii_bus %s failed to register\n", bus->id);
46abc02175b3c24 Lennert Buytenhek      2008-10-08  660  		return -EINVAL;
46abc02175b3c24 Lennert Buytenhek      2008-10-08  661  	}
46abc02175b3c24 Lennert Buytenhek      2008-10-08  662
d1e7fe4d92742dd Adrian Bunk            2008-02-20  663  	mutex_init(&bus->mdio_lock);
6349084746ff4f5 Michael Walle          2020-05-06  664  	mutex_init(&bus->shared_lock);
d1e7fe4d92742dd Adrian Bunk            2008-02-20  665
e0183b974d3008a Mike Looijmans         2021-02-02  666  	/* assert bus level PHY GPIO reset */
e0183b974d3008a Mike Looijmans         2021-02-02  667  	gpiod = devm_gpiod_get_optional(&bus->dev, "reset", GPIOD_OUT_HIGH);
69226896ad636b9 Roger Quadros          2017-04-21  668  	if (IS_ERR(gpiod)) {
0a12ad592955619 Grygorii Strashko      2020-11-19  669  		err = dev_err_probe(&bus->dev, PTR_ERR(gpiod),
0a12ad592955619 Grygorii Strashko      2020-11-19  670  				    "mii_bus %s couldn't get reset GPIO\n",
69226896ad636b9 Roger Quadros          2017-04-21  671  				    bus->id);
e40e2a2e78664fa Thomas Petazzoni       2019-01-16  672  		device_del(&bus->dev);
0a12ad592955619 Grygorii Strashko      2020-11-19  673  		return err;
fe0e4052fb11d5c Sergei Shtylyov        2017-06-12  674  	} else	if (gpiod) {
d396e84c56047b3 Sergei Shtylyov        2017-06-12  675  		bus->reset_gpiod = gpiod;
6259e0f5478d7a7 Bruno Thomsen          2020-07-30  676  		fsleep(bus->reset_delay_us);
69226896ad636b9 Roger Quadros          2017-04-21  677  		gpiod_set_value_cansleep(gpiod, 0);
bb3831294cd5075 Bruno Thomsen          2020-07-30  678  		if (bus->reset_post_delay_us > 0)
bb3831294cd5075 Bruno Thomsen          2020-07-30  679  			fsleep(bus->reset_post_delay_us);
69226896ad636b9 Roger Quadros          2017-04-21  680  	}
69226896ad636b9 Roger Quadros          2017-04-21  681
c290d1ab12d3385 Florian Fainelli       2020-04-18  682  	if (bus->reset) {
c290d1ab12d3385 Florian Fainelli       2020-04-18  683  		err = bus->reset(bus);
c290d1ab12d3385 Florian Fainelli       2020-04-18  684  		if (err)
c290d1ab12d3385 Florian Fainelli       2020-04-18  685  			goto error_reset_gpiod;
c290d1ab12d3385 Florian Fainelli       2020-04-18  686  	}
df0c8d911abf6ba Florian Fainelli       2017-05-11  687
e582444c20a13a5 Andrew Lunn            2022-04-20  688  	if (bus->probe_capabilities == MDIOBUS_NO_CAP ||
e582444c20a13a5 Andrew Lunn            2022-04-20  689  	    bus->probe_capabilities == MDIOBUS_C22 ||
e582444c20a13a5 Andrew Lunn            2022-04-20  690  	    bus->probe_capabilities == MDIOBUS_C22_C45) {
e582444c20a13a5 Andrew Lunn            2022-04-20  691  		err = mdiobus_scan_bus_c22(bus);
e582444c20a13a5 Andrew Lunn            2022-04-20  692  		if (err)
161c8d2f50109b4 Krzysztof Halasa       2008-12-25  693  			goto error;
161c8d2f50109b4 Krzysztof Halasa       2008-12-25  694  	}
e582444c20a13a5 Andrew Lunn            2022-04-20  695
e582444c20a13a5 Andrew Lunn            2022-04-20  696  	if (bus->probe_capabilities == MDIOBUS_C45 ||
e582444c20a13a5 Andrew Lunn            2022-04-20  697  	    bus->probe_capabilities == MDIOBUS_C22_C45) {
e582444c20a13a5 Andrew Lunn            2022-04-20  698  		err = mdiobus_scan_bus_c45(bus);
e582444c20a13a5 Andrew Lunn            2022-04-20  699  		if (err)
e582444c20a13a5 Andrew Lunn            2022-04-20  700  			goto error;
64b1c2b42b555ef Herbert Valerio Riedel 2006-05-10  701  	}
f896424cbc61225 Matt Porter            2005-11-02  702
d0281a56b00c63a Florian Fainelli       2017-03-28  703  	mdiobus_setup_mdiodev_from_board_info(bus, mdiobus_create_device);
648ea0134069cda Florian Fainelli       2017-02-04  704
e8e5752dc0a56a0 Krzysztof Halasa       2008-12-17  705  	bus->state = MDIOBUS_REGISTERED;
7590fc6f80ac2cb Florian Fainelli       2022-01-03  706  	dev_dbg(&bus->dev, "probed\n");
161c8d2f50109b4 Krzysztof Halasa       2008-12-25  707  	return 0;
e13934563db0470 Andy Fleming           2005-08-24  708
161c8d2f50109b4 Krzysztof Halasa       2008-12-25  709  error:
161c8d2f50109b4 Krzysztof Halasa       2008-12-25 @710  	while (--i >= 0) {
711fdba37a3dd7e Andrew Lunn            2016-01-06  711  		mdiodev = bus->mdio_map[i];
711fdba37a3dd7e Andrew Lunn            2016-01-06  712  		if (!mdiodev)
711fdba37a3dd7e Andrew Lunn            2016-01-06  713  			continue;
711fdba37a3dd7e Andrew Lunn            2016-01-06  714
711fdba37a3dd7e Andrew Lunn            2016-01-06  715  		mdiodev->device_remove(mdiodev);
711fdba37a3dd7e Andrew Lunn            2016-01-06  716  		mdiodev->device_free(mdiodev);
161c8d2f50109b4 Krzysztof Halasa       2008-12-25  717  	}
c290d1ab12d3385 Florian Fainelli       2020-04-18  718  error_reset_gpiod:
69226896ad636b9 Roger Quadros          2017-04-21  719  	/* Put PHYs in RESET to save power */
a010a2f6540ecc3 Florian Fainelli       2017-09-08  720  	if (bus->reset_gpiod)
d396e84c56047b3 Sergei Shtylyov        2017-06-12  721  		gpiod_set_value_cansleep(bus->reset_gpiod, 1);
69226896ad636b9 Roger Quadros          2017-04-21  722
161c8d2f50109b4 Krzysztof Halasa       2008-12-25  723  	device_del(&bus->dev);
4fd5f812c23c7de Lennert Buytenhek      2008-08-26  724  	return err;
4fd5f812c23c7de Lennert Buytenhek      2008-08-26  725  }
3e3aaf649416988 Russell King           2015-09-24  726  EXPORT_SYMBOL(__mdiobus_register);
4fd5f812c23c7de Lennert Buytenhek      2008-08-26  727

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ