* [PATCH] Bluetooth: move adv_instance_cnt read within the device lock
@ 2022-02-12 23:14 Niels Dossche
2022-03-04 15:31 ` Marcel Holtmann
0 siblings, 1 reply; 2+ messages in thread
From: Niels Dossche @ 2022-02-12 23:14 UTC (permalink / raw)
To: Marcel Holtmann, Johan Hedberg, Luiz Augusto von Dentz
Cc: linux-bluetooth, linux-kernel
The field adv_instance_cnt is always accessed within a device lock,
except in the function add_advertising. A concurrent remove of an
advertisement with adding another one could result in the if check
"if a new instance was actually added" to not trigger, resulting
in not triggering the "advertising added event".
Signed-off-by: Niels Dossche <niels.dossche@ugent.be>
---
net/bluetooth/mgmt.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 37087cf7dc5a..e0dc72f147b4 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -8046,7 +8046,7 @@ static int add_advertising(struct sock *sk, struct hci_dev *hdev,
u32 flags;
u8 status;
u16 timeout, duration;
- unsigned int prev_instance_cnt = hdev->adv_instance_cnt;
+ unsigned int prev_instance_cnt;
u8 schedule_instance = 0;
struct adv_info *next_instance;
int err;
@@ -8097,6 +8097,8 @@ static int add_advertising(struct sock *sk, struct hci_dev *hdev,
goto unlock;
}
+ prev_instance_cnt = hdev->adv_instance_cnt;
+
err = hci_add_adv_instance(hdev, cp->instance, flags,
cp->adv_data_len, cp->data,
cp->scan_rsp_len,
--
2.34.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Bluetooth: move adv_instance_cnt read within the device lock
2022-02-12 23:14 [PATCH] Bluetooth: move adv_instance_cnt read within the device lock Niels Dossche
@ 2022-03-04 15:31 ` Marcel Holtmann
0 siblings, 0 replies; 2+ messages in thread
From: Marcel Holtmann @ 2022-03-04 15:31 UTC (permalink / raw)
To: Niels Dossche
Cc: Johan Hedberg, Luiz Augusto von Dentz, linux-bluetooth, linux-kernel
Hi Niels,
> The field adv_instance_cnt is always accessed within a device lock,
> except in the function add_advertising. A concurrent remove of an
> advertisement with adding another one could result in the if check
> "if a new instance was actually added" to not trigger, resulting
> in not triggering the "advertising added event".
>
> Signed-off-by: Niels Dossche <niels.dossche@ugent.be>
> ---
> net/bluetooth/mgmt.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
patch has been applied to bluetooth-next tree.
Regards
Marcel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-03-04 15:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-12 23:14 [PATCH] Bluetooth: move adv_instance_cnt read within the device lock Niels Dossche
2022-03-04 15:31 ` Marcel Holtmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®