[bluetooth-next:master 2/2] net/bluetooth/hci_core.c:1447:8: warning: 'invalid_bdaddr' may be used uninitialized in this function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



tree:   https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git master
head:   d6def21fbd55c5ff18b72f179fca09e6beb5058d
commit: d6def21fbd55c5ff18b72f179fca09e6beb5058d [2/2] Bluetooth: Allow combination of BDADDR_PROPERTY and INVALID_BDADDR quirks
config: arm-defconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (GCC) 7.4.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        git checkout d6def21fbd55c5ff18b72f179fca09e6beb5058d
        # save the attached .config to linux build tree
        GCC_VERSION=7.4.0 make.cross ARCH=arm 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@xxxxxxxxx>

Note: it may well be a FALSE warning. FWIW you are at least aware of it now.
http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings

All warnings (new ones prefixed by >>):

   net/bluetooth/hci_core.c: In function 'hci_dev_do_open':
>> net/bluetooth/hci_core.c:1447:8: warning: 'invalid_bdaddr' may be used uninitialized in this function [-Wmaybe-uninitialized]
      bool invalid_bdaddr;
           ^~~~~~~~~~~~~~

vim +/invalid_bdaddr +1447 net/bluetooth/hci_core.c

  1384	
  1385	static int hci_dev_do_open(struct hci_dev *hdev)
  1386	{
  1387		int ret = 0;
  1388	
  1389		BT_DBG("%s %p", hdev->name, hdev);
  1390	
  1391		hci_req_sync_lock(hdev);
  1392	
  1393		if (hci_dev_test_flag(hdev, HCI_UNREGISTER)) {
  1394			ret = -ENODEV;
  1395			goto done;
  1396		}
  1397	
  1398		if (!hci_dev_test_flag(hdev, HCI_SETUP) &&
  1399		    !hci_dev_test_flag(hdev, HCI_CONFIG)) {
  1400			/* Check for rfkill but allow the HCI setup stage to
  1401			 * proceed (which in itself doesn't cause any RF activity).
  1402			 */
  1403			if (hci_dev_test_flag(hdev, HCI_RFKILLED)) {
  1404				ret = -ERFKILL;
  1405				goto done;
  1406			}
  1407	
  1408			/* Check for valid public address or a configured static
  1409			 * random adddress, but let the HCI setup proceed to
  1410			 * be able to determine if there is a public address
  1411			 * or not.
  1412			 *
  1413			 * In case of user channel usage, it is not important
  1414			 * if a public address or static random address is
  1415			 * available.
  1416			 *
  1417			 * This check is only valid for BR/EDR controllers
  1418			 * since AMP controllers do not have an address.
  1419			 */
  1420			if (!hci_dev_test_flag(hdev, HCI_USER_CHANNEL) &&
  1421			    hdev->dev_type == HCI_PRIMARY &&
  1422			    !bacmp(&hdev->bdaddr, BDADDR_ANY) &&
  1423			    !bacmp(&hdev->static_addr, BDADDR_ANY)) {
  1424				ret = -EADDRNOTAVAIL;
  1425				goto done;
  1426			}
  1427		}
  1428	
  1429		if (test_bit(HCI_UP, &hdev->flags)) {
  1430			ret = -EALREADY;
  1431			goto done;
  1432		}
  1433	
  1434		if (hdev->open(hdev)) {
  1435			ret = -EIO;
  1436			goto done;
  1437		}
  1438	
  1439		set_bit(HCI_RUNNING, &hdev->flags);
  1440		hci_sock_dev_event(hdev, HCI_DEV_OPEN);
  1441	
  1442		atomic_set(&hdev->cmd_cnt, 1);
  1443		set_bit(HCI_INIT, &hdev->flags);
  1444	
  1445		if (hci_dev_test_flag(hdev, HCI_SETUP) ||
  1446		    test_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks)) {
> 1447			bool invalid_bdaddr;
  1448	
  1449			hci_sock_dev_event(hdev, HCI_DEV_SETUP);
  1450	
  1451			if (hdev->setup) {
  1452				ret = hdev->setup(hdev);
  1453				if (ret)
  1454					goto setup_failed;
  1455			}
  1456	
  1457			/* The transport driver can set the quirk to mark the
  1458			 * BD_ADDR invalid before creating the HCI device or in
  1459			 * its setup callback.
  1460			 */
  1461			invalid_bdaddr = test_bit(HCI_QUIRK_INVALID_BDADDR,
  1462						  &hdev->quirks);
  1463	
  1464			if (test_bit(HCI_QUIRK_USE_BDADDR_PROPERTY, &hdev->quirks)) {
  1465				if (!bacmp(&hdev->public_addr, BDADDR_ANY))
  1466					hci_dev_get_bd_addr_from_property(hdev);
  1467	
  1468				if (bacmp(&hdev->public_addr, BDADDR_ANY) &&
  1469				    hdev->set_bdaddr) {
  1470					ret = hdev->set_bdaddr(hdev,
  1471							       &hdev->public_addr);
  1472	
  1473					/* If setting of the BD_ADDR from the device
  1474					 * property succeeds, then treat the address
  1475					 * as valid even if the invalid BD_ADDR
  1476					 * quirk indicates otherwise.
  1477					 */
  1478					if (!ret)
  1479						invalid_bdaddr = false;
  1480				}
  1481			}
  1482	
  1483	setup_failed:
  1484			/* The transport driver can set these quirks before
  1485			 * creating the HCI device or in its setup callback.
  1486			 *
  1487			 * For the invalid BD_ADDR quirk it is possible that
  1488			 * it becomes a valid address if the bootloader does
  1489			 * provide it (see above).
  1490			 *
  1491			 * In case any of them is set, the controller has to
  1492			 * start up as unconfigured.
  1493			 */
  1494			if (test_bit(HCI_QUIRK_EXTERNAL_CONFIG, &hdev->quirks) ||
  1495			    invalid_bdaddr)
  1496				hci_dev_set_flag(hdev, HCI_UNCONFIGURED);
  1497	
  1498			/* For an unconfigured controller it is required to
  1499			 * read at least the version information provided by
  1500			 * the Read Local Version Information command.
  1501			 *
  1502			 * If the set_bdaddr driver callback is provided, then
  1503			 * also the original Bluetooth public device address
  1504			 * will be read using the Read BD Address command.
  1505			 */
  1506			if (hci_dev_test_flag(hdev, HCI_UNCONFIGURED))
  1507				ret = __hci_unconf_init(hdev);
  1508		}
  1509	
  1510		if (hci_dev_test_flag(hdev, HCI_CONFIG)) {
  1511			/* If public address change is configured, ensure that
  1512			 * the address gets programmed. If the driver does not
  1513			 * support changing the public address, fail the power
  1514			 * on procedure.
  1515			 */
  1516			if (bacmp(&hdev->public_addr, BDADDR_ANY) &&
  1517			    hdev->set_bdaddr)
  1518				ret = hdev->set_bdaddr(hdev, &hdev->public_addr);
  1519			else
  1520				ret = -EADDRNOTAVAIL;
  1521		}
  1522	
  1523		if (!ret) {
  1524			if (!hci_dev_test_flag(hdev, HCI_UNCONFIGURED) &&
  1525			    !hci_dev_test_flag(hdev, HCI_USER_CHANNEL)) {
  1526				ret = __hci_init(hdev);
  1527				if (!ret && hdev->post_init)
  1528					ret = hdev->post_init(hdev);
  1529			}
  1530		}
  1531	
  1532		/* If the HCI Reset command is clearing all diagnostic settings,
  1533		 * then they need to be reprogrammed after the init procedure
  1534		 * completed.
  1535		 */
  1536		if (test_bit(HCI_QUIRK_NON_PERSISTENT_DIAG, &hdev->quirks) &&
  1537		    !hci_dev_test_flag(hdev, HCI_USER_CHANNEL) &&
  1538		    hci_dev_test_flag(hdev, HCI_VENDOR_DIAG) && hdev->set_diag)
  1539			ret = hdev->set_diag(hdev, true);
  1540	
  1541		clear_bit(HCI_INIT, &hdev->flags);
  1542	
  1543		if (!ret) {
  1544			hci_dev_hold(hdev);
  1545			hci_dev_set_flag(hdev, HCI_RPA_EXPIRED);
  1546			hci_adv_instances_set_rpa_expired(hdev, true);
  1547			set_bit(HCI_UP, &hdev->flags);
  1548			hci_sock_dev_event(hdev, HCI_DEV_UP);
  1549			hci_leds_update_powered(hdev, true);
  1550			if (!hci_dev_test_flag(hdev, HCI_SETUP) &&
  1551			    !hci_dev_test_flag(hdev, HCI_CONFIG) &&
  1552			    !hci_dev_test_flag(hdev, HCI_UNCONFIGURED) &&
  1553			    !hci_dev_test_flag(hdev, HCI_USER_CHANNEL) &&
  1554			    hci_dev_test_flag(hdev, HCI_MGMT) &&
  1555			    hdev->dev_type == HCI_PRIMARY) {
  1556				ret = __hci_req_hci_power_on(hdev);
  1557				mgmt_power_on(hdev, ret);
  1558			}
  1559		} else {
  1560			/* Init failed, cleanup */
  1561			flush_work(&hdev->tx_work);
  1562			flush_work(&hdev->cmd_work);
  1563			flush_work(&hdev->rx_work);
  1564	
  1565			skb_queue_purge(&hdev->cmd_q);
  1566			skb_queue_purge(&hdev->rx_q);
  1567	
  1568			if (hdev->flush)
  1569				hdev->flush(hdev);
  1570	
  1571			if (hdev->sent_cmd) {
  1572				kfree_skb(hdev->sent_cmd);
  1573				hdev->sent_cmd = NULL;
  1574			}
  1575	
  1576			clear_bit(HCI_RUNNING, &hdev->flags);
  1577			hci_sock_dev_event(hdev, HCI_DEV_CLOSE);
  1578	
  1579			hdev->close(hdev);
  1580			hdev->flags &= BIT(HCI_RAW);
  1581		}
  1582	
  1583	done:
  1584		hci_req_sync_unlock(hdev);
  1585		return ret;
  1586	}
  1587	

---
0-DAY kernel test infrastructure                 Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx Intel Corporation

Attachment: .config.gz
Description: application/gzip


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux