mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-03 15:47:36 +00:00
Bluetooth: hci_sync: fix memory leak in hci_update_adv_data()
[ Upstream commit1ed8b37cba
] When hci_cmd_sync_queue() failed in hci_update_adv_data(), inst_ptr is not freed, which will cause memory leak, convert to use ERR_PTR/PTR_ERR to pass the instance to callback so no memory needs to be allocated. Fixes:651cd3d65b
("Bluetooth: convert hci_update_adv_data to hci_sync") Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
f51a825b9f
commit
8ac6043bd3
1 changed files with 3 additions and 10 deletions
|
@ -6168,20 +6168,13 @@ int hci_get_random_address(struct hci_dev *hdev, bool require_privacy,
|
|||
|
||||
static int _update_adv_data_sync(struct hci_dev *hdev, void *data)
|
||||
{
|
||||
u8 instance = *(u8 *)data;
|
||||
|
||||
kfree(data);
|
||||
u8 instance = PTR_ERR(data);
|
||||
|
||||
return hci_update_adv_data_sync(hdev, instance);
|
||||
}
|
||||
|
||||
int hci_update_adv_data(struct hci_dev *hdev, u8 instance)
|
||||
{
|
||||
u8 *inst_ptr = kmalloc(1, GFP_KERNEL);
|
||||
|
||||
if (!inst_ptr)
|
||||
return -ENOMEM;
|
||||
|
||||
*inst_ptr = instance;
|
||||
return hci_cmd_sync_queue(hdev, _update_adv_data_sync, inst_ptr, NULL);
|
||||
return hci_cmd_sync_queue(hdev, _update_adv_data_sync,
|
||||
ERR_PTR(instance), NULL);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue