summaryrefslogtreecommitdiffstats
path: root/net/bluetooth/eir.h
diff options
context:
space:
mode:
authorRadoslaw Biernacki <rad@semihalf.com>2022-02-01 21:10:32 +0100
committerMarcel Holtmann <marcel@holtmann.org>2022-03-04 16:10:49 +0100
commitba17bb62ce415950753c19d16bb43b2bd3701158 (patch)
treec0a044ebf28c3a2ad141c6db786f75a77e4c8ad1 /net/bluetooth/eir.h
parentBluetooth: mgmt: Remove unneeded variable (diff)
downloadlinux-ba17bb62ce415950753c19d16bb43b2bd3701158.tar.xz
linux-ba17bb62ce415950753c19d16bb43b2bd3701158.zip
Bluetooth: Fix skb allocation in mgmt_remote_name() & mgmt_device_connected()
This patch fixes skb allocation, as lack of space for ev might push skb tail beyond its end. Also introduce eir_precalc_len() that can be used instead of magic numbers for similar eir operations on skb. Fixes: cf1bce1de7eeb ("Bluetooth: mgmt: Make use of mgmt_send_event_skb in MGMT_EV_DEVICE_FOUND") Fixes: e96741437ef0a ("Bluetooth: mgmt: Make use of mgmt_send_event_skb in MGMT_EV_DEVICE_CONNECTED") Signed-off-by: Angela Czubak <acz@semihalf.com> Signed-off-by: Marek Maslanka <mm@semihalf.com> Signed-off-by: Radoslaw Biernacki <rad@semihalf.com> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Diffstat (limited to 'net/bluetooth/eir.h')
-rw-r--r--net/bluetooth/eir.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/net/bluetooth/eir.h b/net/bluetooth/eir.h
index 05e2e917fc25..e5876751f07e 100644
--- a/net/bluetooth/eir.h
+++ b/net/bluetooth/eir.h
@@ -15,6 +15,11 @@ u8 eir_create_scan_rsp(struct hci_dev *hdev, u8 instance, u8 *ptr);
u8 eir_append_local_name(struct hci_dev *hdev, u8 *eir, u8 ad_len);
u8 eir_append_appearance(struct hci_dev *hdev, u8 *ptr, u8 ad_len);
+static inline u16 eir_precalc_len(u8 data_len)
+{
+ return sizeof(u8) * 2 + data_len;
+}
+
static inline u16 eir_append_data(u8 *eir, u16 eir_len, u8 type,
u8 *data, u8 data_len)
{