Building the Linux kernel with Clang and LLVM
 help / color / mirror / Atom feed
* Re: [PATCH] Bluetooth: MGMT: Serialize power-on with power-off completion
       [not found] <pm-bluetooth-objects-candidate-0063-v7-35a6680c94a332fea155@gmail.com>
@ 2026-10-14 19:11 ` kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2026-10-14 19:11 UTC (permalink / raw)
  To: Cen Zhang, marcel, luiz.dentz, padovan, johan.hedberg
  Cc: llvm, oe-kbuild-all, linux-bluetooth, linux-kernel, baijiaju1990,
	jjzuming, zzzccc427

Hi Cen,

kernel test robot noticed the following build warnings:

[auto build test WARNING on bluetooth/master]
[also build test WARNING on bluetooth-next/master linus/master v7.3-rc7 next-20261012]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Cen-Zhang/Bluetooth-MGMT-Serialize-power-on-with-power-off-completion/20261014-002814
base:   https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth.git master
patch link:    https://lore.kernel.org/r/pm-bluetooth-objects-candidate-0063-v7-35a6680c94a332fea155%40gmail.com
patch subject: [PATCH] Bluetooth: MGMT: Serialize power-on with power-off completion
config: arm64-randconfig-1000-20261014 (https://download.01.org/0day-ci/archive/20261015/202610150313.1x2NMEsK-lkp@intel.com/config)
compiler: clang version 24.0.0git (https://github.com/llvm/llvm-project 6719b9e31d6a93099612c474eec76d9f41d0275a)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261015/202610150313.1x2NMEsK-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202610150313.1x2NMEsK-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> net/bluetooth/mgmt.c:1415:2: warning: mutex 'hdev->req_lock' is not held on every path through here [-Wthread-safety-analysis]
    1415 |         hci_dev_lock(hdev);
         |         ^
   include/net/bluetooth/hci_core.h:1752:26: note: expanded from macro 'hci_dev_lock'
    1752 | #define hci_dev_lock(d)         mutex_lock(&d->lock)
         |                                 ^
   include/linux/mutex.h:193:26: note: expanded from macro 'mutex_lock'
     193 | #define mutex_lock(lock) mutex_lock_nested(lock, 0)
         |                          ^
   net/bluetooth/mgmt.c:1413:3: note: mutex acquired here
    1413 |                 hci_req_sync_lock(hdev);
         |                 ^
   include/net/bluetooth/hci_sync.h:15:35: note: expanded from macro 'hci_req_sync_lock'
      15 | #define hci_req_sync_lock(hdev)   mutex_lock(&hdev->req_lock)
         |                                   ^
   include/linux/mutex.h:193:26: note: expanded from macro 'mutex_lock'
     193 | #define mutex_lock(lock) mutex_lock_nested(lock, 0)
         |                          ^
>> net/bluetooth/mgmt.c:1459:3: warning: releasing mutex 'hdev->req_lock' that was not held [-Wthread-safety-analysis]
    1459 |                 hci_req_sync_unlock(hdev);
         |                 ^
   include/net/bluetooth/hci_sync.h:16:35: note: expanded from macro 'hci_req_sync_unlock'
      16 | #define hci_req_sync_unlock(hdev) mutex_unlock(&hdev->req_lock)
         |                                   ^
   2 warnings generated.


vim +1415 net/bluetooth/mgmt.c

8b064a3ad377c01 Johan Hedberg          2014-02-24  1394  
bdb6d97154b7b7e Johan Hedberg          2012-02-28  1395  static int set_powered(struct sock *sk, struct hci_dev *hdev, void *data,
bdb6d97154b7b7e Johan Hedberg          2012-02-28  1396  		       u16 len)
eec8d2bcc841ae4 Johan Hedberg          2010-12-16  1397  {
650f726d16a3f25 Vinicius Costa Gomes   2012-02-02  1398  	struct mgmt_mode *cp = data;
3b0602cd01a5711 Johan Hedberg          2015-03-06  1399  	struct mgmt_pending_cmd *cmd;
4b34ee782164fba Johan Hedberg          2012-02-21  1400  	int err;
eec8d2bcc841ae4 Johan Hedberg          2010-12-16  1401  
181d695352305cc Marcel Holtmann        2020-05-06  1402  	bt_dev_dbg(hdev, "sock %p", sk);
eec8d2bcc841ae4 Johan Hedberg          2010-12-16  1403  
a7e80f25ae2296d Johan Hedberg          2013-01-09  1404  	if (cp->val != 0x00 && cp->val != 0x01)
a69e8375a134eb7 Johan Hedberg          2015-03-06  1405  		return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_POWERED,
a7e80f25ae2296d Johan Hedberg          2013-01-09  1406  				       MGMT_STATUS_INVALID_PARAMS);
a7e80f25ae2296d Johan Hedberg          2013-01-09  1407  
0ec18e0eaccffd5 Cen Zhang              2026-10-14  1408  	/*
0ec18e0eaccffd5 Cen Zhang              2026-10-14  1409  	 * Wait for the previous power-off completion before publishing a
0ec18e0eaccffd5 Cen Zhang              2026-10-14  1410  	 * new command that could reuse its freed pending-command address.
0ec18e0eaccffd5 Cen Zhang              2026-10-14  1411  	 */
0ec18e0eaccffd5 Cen Zhang              2026-10-14  1412  	if (cp->val)
0ec18e0eaccffd5 Cen Zhang              2026-10-14  1413  		hci_req_sync_lock(hdev);
0ec18e0eaccffd5 Cen Zhang              2026-10-14  1414  
09fd0de5bd8f8ef Gustavo Padovan        2011-06-17 @1415  	hci_dev_lock(hdev);
eec8d2bcc841ae4 Johan Hedberg          2010-12-16  1416  
b14202aff5acba3 Jonas Dreßler          2024-01-07  1417  	if (!cp->val) {
b14202aff5acba3 Jonas Dreßler          2024-01-07  1418  		if (hci_dev_test_flag(hdev, HCI_POWERING_DOWN)) {
b14202aff5acba3 Jonas Dreßler          2024-01-07  1419  			err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_POWERED,
b14202aff5acba3 Jonas Dreßler          2024-01-07  1420  					      MGMT_STATUS_BUSY);
b14202aff5acba3 Jonas Dreßler          2024-01-07  1421  			goto failed;
b14202aff5acba3 Jonas Dreßler          2024-01-07  1422  		}
b14202aff5acba3 Jonas Dreßler          2024-01-07  1423  	}
b14202aff5acba3 Jonas Dreßler          2024-01-07  1424  
333ae95d054519f Johan Hedberg          2015-03-17  1425  	if (pending_find(MGMT_OP_SET_POWERED, hdev)) {
a69e8375a134eb7 Johan Hedberg          2015-03-06  1426  		err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_POWERED,
87b95ba64efcfcf Johan Hedberg          2013-09-25  1427  				      MGMT_STATUS_BUSY);
87b95ba64efcfcf Johan Hedberg          2013-09-25  1428  		goto failed;
87b95ba64efcfcf Johan Hedberg          2013-09-25  1429  	}
87b95ba64efcfcf Johan Hedberg          2013-09-25  1430  
4b34ee782164fba Johan Hedberg          2012-02-21  1431  	if (!!cp->val == hdev_is_powered(hdev)) {
69ab39ea5da03e6 Johan Hedberg          2011-12-15  1432  		err = send_settings_rsp(sk, MGMT_OP_SET_POWERED, hdev);
eec8d2bcc841ae4 Johan Hedberg          2010-12-16  1433  		goto failed;
eec8d2bcc841ae4 Johan Hedberg          2010-12-16  1434  	}
eec8d2bcc841ae4 Johan Hedberg          2010-12-16  1435  
275f3f64870245b Brian Gix              2022-03-01  1436  	cmd = mgmt_pending_add(sk, MGMT_OP_SET_POWERED, hdev, data, len);
366a033698266c3 Johan Hedberg          2011-02-19  1437  	if (!cmd) {
366a033698266c3 Johan Hedberg          2011-02-19  1438  		err = -ENOMEM;
eec8d2bcc841ae4 Johan Hedberg          2010-12-16  1439  		goto failed;
366a033698266c3 Johan Hedberg          2011-02-19  1440  	}
eec8d2bcc841ae4 Johan Hedberg          2010-12-16  1441  
f419863588217f7 Archie Pusaka          2023-04-20  1442  	/* Cancel potentially blocking sync operation before power off */
d883a4669a1def6 Luiz Augusto von Dentz 2023-04-21  1443  	if (cp->val == 0x00) {
63298d6e752fc0e Luiz Augusto von Dentz 2024-01-09  1444  		hci_cmd_sync_cancel_sync(hdev, -EHOSTDOWN);
cf75ad8b41d2aa0 Luiz Augusto von Dentz 2021-10-27  1445  		err = hci_cmd_sync_queue(hdev, set_powered_sync, cmd,
cf75ad8b41d2aa0 Luiz Augusto von Dentz 2021-10-27  1446  					 mgmt_set_powered_complete);
d883a4669a1def6 Luiz Augusto von Dentz 2023-04-21  1447  	} else {
d883a4669a1def6 Luiz Augusto von Dentz 2023-04-21  1448  		/* Use hci_cmd_sync_submit since hdev might not be running */
d883a4669a1def6 Luiz Augusto von Dentz 2023-04-21  1449  		err = hci_cmd_sync_submit(hdev, set_powered_sync, cmd,
d883a4669a1def6 Luiz Augusto von Dentz 2023-04-21  1450  					  mgmt_set_powered_complete);
d883a4669a1def6 Luiz Augusto von Dentz 2023-04-21  1451  	}
eec8d2bcc841ae4 Johan Hedberg          2010-12-16  1452  
275f3f64870245b Brian Gix              2022-03-01  1453  	if (err < 0)
275f3f64870245b Brian Gix              2022-03-01  1454  		mgmt_pending_remove(cmd);
275f3f64870245b Brian Gix              2022-03-01  1455  
eec8d2bcc841ae4 Johan Hedberg          2010-12-16  1456  failed:
09fd0de5bd8f8ef Gustavo Padovan        2011-06-17  1457  	hci_dev_unlock(hdev);
0ec18e0eaccffd5 Cen Zhang              2026-10-14  1458  	if (cp->val)
0ec18e0eaccffd5 Cen Zhang              2026-10-14 @1459  		hci_req_sync_unlock(hdev);
366a033698266c3 Johan Hedberg          2011-02-19  1460  	return err;
eec8d2bcc841ae4 Johan Hedberg          2010-12-16  1461  }
eec8d2bcc841ae4 Johan Hedberg          2010-12-16  1462  

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-10-14 19:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <pm-bluetooth-objects-candidate-0063-v7-35a6680c94a332fea155@gmail.com>
2026-10-14 19:11 ` [PATCH] Bluetooth: MGMT: Serialize power-on with power-off completion kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox