linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* RE: [v2] Bluetooth: hci_sync: fix memory leak in hci_update_adv_data()
  2023-01-09 21:22 Luiz Augusto von Dentz
@ 2023-01-09 21:47 ` bluez.test.bot
  0 siblings, 0 replies; 4+ messages in thread
From: bluez.test.bot @ 2023-01-09 21:47 UTC (permalink / raw)
  To: linux-bluetooth, luiz.dentz

[-- Attachment #1: Type: text/plain, Size: 1420 bytes --]

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=710258

---Test result---

Test Summary:
CheckPatch                    PASS      0.67 seconds
GitLint                       PASS      0.33 seconds
SubjectPrefix                 PASS      0.12 seconds
BuildKernel                   PASS      31.67 seconds
CheckAllWarning               PASS      35.17 seconds
CheckSparse                   PASS      39.31 seconds
CheckSmatch                   PASS      108.95 seconds
BuildKernel32                 PASS      30.51 seconds
TestRunnerSetup               PASS      441.76 seconds
TestRunner_l2cap-tester       PASS      16.00 seconds
TestRunner_iso-tester         PASS      16.45 seconds
TestRunner_bnep-tester        PASS      5.54 seconds
TestRunner_mgmt-tester        PASS      107.57 seconds
TestRunner_rfcomm-tester      PASS      8.77 seconds
TestRunner_sco-tester         PASS      8.04 seconds
TestRunner_ioctl-tester       PASS      9.25 seconds
TestRunner_mesh-tester        PASS      6.85 seconds
TestRunner_smp-tester         PASS      7.98 seconds
TestRunner_userchan-tester    PASS      5.75 seconds
IncrementalBuild              PASS      28.72 seconds



---
Regards,
Linux Bluetooth


^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [v2] Bluetooth: hci_sync: fix memory leak in hci_update_adv_data()
  2023-01-10  6:44 [PATCH v2] Bluetooth: hci_sync: fix memory leak in hci_update_adv_data() Zhengchao Shao
@ 2023-01-10  6:42 ` bluez.test.bot
  2023-01-10  7:05 ` [PATCH v2] " shaozhengchao
  1 sibling, 0 replies; 4+ messages in thread
From: bluez.test.bot @ 2023-01-10  6:42 UTC (permalink / raw)
  To: linux-bluetooth, shaozhengchao

[-- Attachment #1: Type: text/plain, Size: 551 bytes --]

This is an automated email and please do not reply to this email.

Dear Submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
While preparing the CI tests, the patches you submitted couldn't be applied to the current HEAD of the repository.

----- Output -----

error: patch failed: net/bluetooth/hci_sync.c:6187
error: net/bluetooth/hci_sync.c: patch does not apply
hint: Use 'git am --show-current-patch' to see the failed patch

Please resolve the issue and submit the patches again.


---
Regards,
Linux Bluetooth


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2] Bluetooth: hci_sync: fix memory leak in hci_update_adv_data()
@ 2023-01-10  6:44 Zhengchao Shao
  2023-01-10  6:42 ` [v2] " bluez.test.bot
  2023-01-10  7:05 ` [PATCH v2] " shaozhengchao
  0 siblings, 2 replies; 4+ messages in thread
From: Zhengchao Shao @ 2023-01-10  6:44 UTC (permalink / raw)
  To: linux-bluetooth, netdev, marcel, johan.hedberg, luiz.dentz, davem,
	edumazet, kuba, pabeni
  Cc: brian.gix, weiyongjun1, yuehaibing, shaozhengchao

When hci_cmd_sync_queue() failed in hci_update_adv_data(), inst_ptr is
not freed, which will cause memory leak. ERR_PTR/PTR_ERR is used to
replace memory allocation to simplify code.

Fixes: 651cd3d65b0f ("Bluetooth: convert hci_update_adv_data to hci_sync")
Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
---
v2: Use ERR_PTR/PTR_ERR to replace memory allocation
---
 net/bluetooth/hci_sync.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
index 9e2d7e4b850c..8744bbecac9e 100644
--- a/net/bluetooth/hci_sync.c
+++ b/net/bluetooth/hci_sync.c
@@ -6187,20 +6187,14 @@ 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;
+	u8 *inst_ptr = ERR_PTR(instance);
 
-	*inst_ptr = instance;
 	return hci_cmd_sync_queue(hdev, _update_adv_data_sync, inst_ptr, NULL);
 }
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] Bluetooth: hci_sync: fix memory leak in hci_update_adv_data()
  2023-01-10  6:44 [PATCH v2] Bluetooth: hci_sync: fix memory leak in hci_update_adv_data() Zhengchao Shao
  2023-01-10  6:42 ` [v2] " bluez.test.bot
@ 2023-01-10  7:05 ` shaozhengchao
  1 sibling, 0 replies; 4+ messages in thread
From: shaozhengchao @ 2023-01-10  7:05 UTC (permalink / raw)
  To: linux-bluetooth, netdev, marcel, johan.hedberg, luiz.dentz, davem,
	edumazet, kuba, pabeni
  Cc: brian.gix, weiyongjun1, yuehaibing


Sorry for Repeatedly senting. Please ignore this patch.

On 2023/1/10 14:44, Zhengchao Shao wrote:
> When hci_cmd_sync_queue() failed in hci_update_adv_data(), inst_ptr is
> not freed, which will cause memory leak. ERR_PTR/PTR_ERR is used to
> replace memory allocation to simplify code.
> 
> Fixes: 651cd3d65b0f ("Bluetooth: convert hci_update_adv_data to hci_sync")
> Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
> ---
> v2: Use ERR_PTR/PTR_ERR to replace memory allocation
> ---
>   net/bluetooth/hci_sync.c | 10 ++--------
>   1 file changed, 2 insertions(+), 8 deletions(-)
> 
> diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
> index 9e2d7e4b850c..8744bbecac9e 100644
> --- a/net/bluetooth/hci_sync.c
> +++ b/net/bluetooth/hci_sync.c
> @@ -6187,20 +6187,14 @@ 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;
> +	u8 *inst_ptr = ERR_PTR(instance);
>   
> -	*inst_ptr = instance;
>   	return hci_cmd_sync_queue(hdev, _update_adv_data_sync, inst_ptr, NULL);
>   }

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-01-10  7:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-10  6:44 [PATCH v2] Bluetooth: hci_sync: fix memory leak in hci_update_adv_data() Zhengchao Shao
2023-01-10  6:42 ` [v2] " bluez.test.bot
2023-01-10  7:05 ` [PATCH v2] " shaozhengchao
  -- strict thread matches above, loose matches on Subject: below --
2023-01-09 21:22 Luiz Augusto von Dentz
2023-01-09 21:47 ` [v2] " bluez.test.bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).