[PATCH][next] Bluetooth: use bitmap_empty to check if a bitmap has any bits set

Subsystems: bluetooth subsystem, the rest

STALE1774d

5 messages, 3 authors, 2021-10-07 · open the first message on its own page

[PATCH][next] Bluetooth: use bitmap_empty to check if a bitmap has any bits set

From: Colin King <hidden>
Date: 2021-10-07 11:17:28

From: Colin Ian King <redacted>

The check to see if any tasks are left checks if bitmap array is zero
rather than using the appropriate bitmap helper functions to check the
bits in the array. Fix this by using bitmap_empty on the bitmap.

Addresses-Coverity: (" Array compared against 0")
Fixes: 912730b52552 ("Bluetooth: Fix wake up suspend_wait_q prematurely")
Signed-off-by: Colin Ian King <redacted>
---
 net/bluetooth/hci_request.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c
index 209f4fe17237..bad3b9c895ba 100644
--- a/net/bluetooth/hci_request.c
+++ b/net/bluetooth/hci_request.c
@@ -1108,7 +1108,7 @@ static void suspend_req_complete(struct hci_dev *hdev, u8 status, u16 opcode)
 	clear_bit(SUSPEND_SET_ADV_FILTER, hdev->suspend_tasks);
 
 	/* Wake up only if there are no tasks left */
-	if (!hdev->suspend_tasks)
+	if (!bitmap_empty(hdev->suspend_tasks, __SUSPEND_NUM_TASKS))
 		wake_up(&hdev->suspend_wait_q);
 }
 
-- 
2.32.0

Re: [PATCH][next] Bluetooth: use bitmap_empty to check if a bitmap has any bits set

From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Date: 2021-10-07 15:35:11

Hi Colin,

On Thu, Oct 7, 2021 at 4:17 AM Colin King [off-list ref] wrote:
quoted hunk
From: Colin Ian King <redacted>

The check to see if any tasks are left checks if bitmap array is zero
rather than using the appropriate bitmap helper functions to check the
bits in the array. Fix this by using bitmap_empty on the bitmap.

Addresses-Coverity: (" Array compared against 0")
Fixes: 912730b52552 ("Bluetooth: Fix wake up suspend_wait_q prematurely")
Signed-off-by: Colin Ian King <redacted>
---
 net/bluetooth/hci_request.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c
index 209f4fe17237..bad3b9c895ba 100644
--- a/net/bluetooth/hci_request.c
+++ b/net/bluetooth/hci_request.c
@@ -1108,7 +1108,7 @@ static void suspend_req_complete(struct hci_dev *hdev, u8 status, u16 opcode)
        clear_bit(SUSPEND_SET_ADV_FILTER, hdev->suspend_tasks);

        /* Wake up only if there are no tasks left */
-       if (!hdev->suspend_tasks)
+       if (!bitmap_empty(hdev->suspend_tasks, __SUSPEND_NUM_TASKS))
                wake_up(&hdev->suspend_wait_q);
 }

--
2.32.0
I was going to revert this change since it appears wake_up does
actually check the wake condition there is no premature wake up after
all.

-- 
Luiz Augusto von Dentz

Re: [PATCH][next] Bluetooth: use bitmap_empty to check if a bitmap has any bits set

From: Colin Ian King <hidden>
Date: 2021-10-07 15:39:13

On 07/10/2021 16:34, Luiz Augusto von Dentz wrote:
Hi Colin,

On Thu, Oct 7, 2021 at 4:17 AM Colin King [off-list ref] wrote:
quoted
From: Colin Ian King <redacted>

The check to see if any tasks are left checks if bitmap array is zero
rather than using the appropriate bitmap helper functions to check the
bits in the array. Fix this by using bitmap_empty on the bitmap.

Addresses-Coverity: (" Array compared against 0")
Fixes: 912730b52552 ("Bluetooth: Fix wake up suspend_wait_q prematurely")
Signed-off-by: Colin Ian King <redacted>
---
  net/bluetooth/hci_request.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c
index 209f4fe17237..bad3b9c895ba 100644
--- a/net/bluetooth/hci_request.c
+++ b/net/bluetooth/hci_request.c
@@ -1108,7 +1108,7 @@ static void suspend_req_complete(struct hci_dev *hdev, u8 status, u16 opcode)
         clear_bit(SUSPEND_SET_ADV_FILTER, hdev->suspend_tasks);

         /* Wake up only if there are no tasks left */
-       if (!hdev->suspend_tasks)
+       if (!bitmap_empty(hdev->suspend_tasks, __SUSPEND_NUM_TASKS))
                 wake_up(&hdev->suspend_wait_q);
  }

--
2.32.0
I was going to revert this change since it appears wake_up does
actually check the wake condition there is no premature wake up after
all.
OK, makes sense.

Colin

Re: [PATCH][next] Bluetooth: use bitmap_empty to check if a bitmap has any bits set

From: Marcel Holtmann <marcel@holtmann.org>
Date: 2021-10-07 15:47:46

Hi Luiz,
quoted
The check to see if any tasks are left checks if bitmap array is zero
rather than using the appropriate bitmap helper functions to check the
bits in the array. Fix this by using bitmap_empty on the bitmap.

Addresses-Coverity: (" Array compared against 0")
Fixes: 912730b52552 ("Bluetooth: Fix wake up suspend_wait_q prematurely")
Signed-off-by: Colin Ian King <redacted>
---
net/bluetooth/hci_request.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c
index 209f4fe17237..bad3b9c895ba 100644
--- a/net/bluetooth/hci_request.c
+++ b/net/bluetooth/hci_request.c
@@ -1108,7 +1108,7 @@ static void suspend_req_complete(struct hci_dev *hdev, u8 status, u16 opcode)
       clear_bit(SUSPEND_SET_ADV_FILTER, hdev->suspend_tasks);

       /* Wake up only if there are no tasks left */
-       if (!hdev->suspend_tasks)
+       if (!bitmap_empty(hdev->suspend_tasks, __SUSPEND_NUM_TASKS))
               wake_up(&hdev->suspend_wait_q);
}

--
2.32.0
I was going to revert this change since it appears wake_up does
actually check the wake condition there is no premature wake up after
all.
so should I take the patch "Fix wake up suspend_wait_q prematurely” completely out?

Regards

Marcel

Re: [PATCH][next] Bluetooth: use bitmap_empty to check if a bitmap has any bits set

From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Date: 2021-10-07 15:54:09

Hi Marcel,

On Thu, Oct 7, 2021 at 8:47 AM Marcel Holtmann [off-list ref] wrote:
Hi Luiz,
quoted
quoted
The check to see if any tasks are left checks if bitmap array is zero
rather than using the appropriate bitmap helper functions to check the
bits in the array. Fix this by using bitmap_empty on the bitmap.

Addresses-Coverity: (" Array compared against 0")
Fixes: 912730b52552 ("Bluetooth: Fix wake up suspend_wait_q prematurely")
Signed-off-by: Colin Ian King <redacted>
---
net/bluetooth/hci_request.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c
index 209f4fe17237..bad3b9c895ba 100644
--- a/net/bluetooth/hci_request.c
+++ b/net/bluetooth/hci_request.c
@@ -1108,7 +1108,7 @@ static void suspend_req_complete(struct hci_dev *hdev, u8 status, u16 opcode)
       clear_bit(SUSPEND_SET_ADV_FILTER, hdev->suspend_tasks);

       /* Wake up only if there are no tasks left */
-       if (!hdev->suspend_tasks)
+       if (!bitmap_empty(hdev->suspend_tasks, __SUSPEND_NUM_TASKS))
               wake_up(&hdev->suspend_wait_q);
}

--
2.32.0
I was going to revert this change since it appears wake_up does
actually check the wake condition there is no premature wake up after
all.
so should I take the patch "Fix wake up suspend_wait_q prematurely” completely out?
Yes, please take it out.

-- 
Luiz Augusto von Dentz
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help