Skip to contentSkip to conversation

Bluetooth: Fix warning of uninitialized adv_instance variable

PATCH In review Johan Hedberg 2 participants 2 messages Jun 18, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Bluetooth: Fix warning of uninitialized adv_instance variable

From: Johan Hedberg <[email protected]>

Some static checkers may cause the following (false positive) warning:

Quoted 1 line
Quoted 1 line

net/bluetooth/mgmt.c:7294:29: warning: 'adv_instance' may be used

uninitialized in this function [-Wuninitialized]

Fix it by ensuring adv_instance always gets set to a known value.

---
 net/bluetooth/mgmt.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
net/bluetooth/mgmt.c +3 -1
index 2fe6f3bfc579..2b3411136d68 100644
@@ -7291,8 +7291,10 @@ static int remove_advertising(struct sock *sk, struct hci_dev *hdev,
 
 	if (cp->instance)
 		adv_instance = hci_find_adv_instance(hdev, cp->instance);
+	else
+		adv_instance = NULL;
 
-	if (!(cp->instance == 0x00 || adv_instance)) {
+	if (!adv_instance) {
 		err = mgmt_cmd_status(sk, hdev->id,
 				      MGMT_OP_REMOVE_ADVERTISING,
 				      MGMT_STATUS_INVALID_PARAMS);
Signature · 1 line
2.4.3
maintainer
#1 lore raw

Hi Johan,

Quoted 11 lines

Some static checkers may cause the following (false positive) warning:

Quoted 1 line
Quoted 1 line

net/bluetooth/mgmt.c:7294:29: warning: 'adv_instance' may be used

uninitialized in this function [-Wuninitialized]

Fix it by ensuring adv_instance always gets set to a known value.

---
net/bluetooth/mgmt.c | 4 +++-

1 file changed, 3 insertions(+), 1 deletion(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel