public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ v1] gatt-server: fix memory leak in bt_gatt_server_send_notification()
@ 2024-06-27 15:09 Roman Smirnov
  2024-06-27 16:40 ` [BlueZ,v1] " bluez.test.bot
  2024-06-27 18:31 ` [PATCH BlueZ v1] " Luiz Augusto von Dentz
  0 siblings, 2 replies; 3+ messages in thread
From: Roman Smirnov @ 2024-06-27 15:09 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Roman Smirnov

data-pdu is allocated but not released when an error occurs.

Add data-pdu release before exiting the function in case of an error.

Found by Linux Verification Center (linuxtesting.org) with the SVACE
static analysis tool.
---
 src/shared/gatt-server.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/shared/gatt-server.c b/src/shared/gatt-server.c
index 0e399ceb1..fb8819c70 100644
--- a/src/shared/gatt-server.c
+++ b/src/shared/gatt-server.c
@@ -1822,6 +1822,7 @@ bool bt_gatt_server_send_notification(struct bt_gatt_server *server,
 	return result;
 
 error:
+	free(data->pdu);
 	if (data)
 		free(data);
 
-- 
2.43.0


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

* RE: [BlueZ,v1] gatt-server: fix memory leak in bt_gatt_server_send_notification()
  2024-06-27 15:09 [PATCH BlueZ v1] gatt-server: fix memory leak in bt_gatt_server_send_notification() Roman Smirnov
@ 2024-06-27 16:40 ` bluez.test.bot
  2024-06-27 18:31 ` [PATCH BlueZ v1] " Luiz Augusto von Dentz
  1 sibling, 0 replies; 3+ messages in thread
From: bluez.test.bot @ 2024-06-27 16:40 UTC (permalink / raw)
  To: linux-bluetooth, r.smirnov

[-- Attachment #1: Type: text/plain, Size: 1707 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=866206

---Test result---

Test Summary:
CheckPatch                    PASS      0.44 seconds
GitLint                       PASS      0.33 seconds
BuildEll                      PASS      24.60 seconds
BluezMake                     PASS      1669.13 seconds
MakeCheck                     PASS      13.04 seconds
MakeDistcheck                 PASS      177.63 seconds
CheckValgrind                 PASS      252.82 seconds
CheckSmatch                   WARNING   353.79 seconds
bluezmakeextell               PASS      120.50 seconds
IncrementalBuild              PASS      1414.90 seconds
ScanBuild                     PASS      1002.35 seconds

Details
##############################
Test: CheckSmatch - WARNING
Desc: Run smatch tool with source
Output:
src/shared/gatt-server.c:278:25: warning: Variable length array is used.src/shared/gatt-server.c:621:25: warning: Variable length array is used.src/shared/gatt-server.c:720:25: warning: Variable length array is used.src/shared/gatt-server.c:278:25: warning: Variable length array is used.src/shared/gatt-server.c:621:25: warning: Variable length array is used.src/shared/gatt-server.c:720:25: warning: Variable length array is used.src/shared/gatt-server.c:278:25: warning: Variable length array is used.src/shared/gatt-server.c:621:25: warning: Variable length array is used.src/shared/gatt-server.c:720:25: warning: Variable length array is used.


---
Regards,
Linux Bluetooth


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

* Re: [PATCH BlueZ v1] gatt-server: fix memory leak in bt_gatt_server_send_notification()
  2024-06-27 15:09 [PATCH BlueZ v1] gatt-server: fix memory leak in bt_gatt_server_send_notification() Roman Smirnov
  2024-06-27 16:40 ` [BlueZ,v1] " bluez.test.bot
@ 2024-06-27 18:31 ` Luiz Augusto von Dentz
  1 sibling, 0 replies; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2024-06-27 18:31 UTC (permalink / raw)
  To: Roman Smirnov; +Cc: linux-bluetooth

Hi Roman,

On Thu, Jun 27, 2024 at 11:11 AM Roman Smirnov <r.smirnov@omp.ru> wrote:
>
> data-pdu is allocated but not released when an error occurs.
>
> Add data-pdu release before exiting the function in case of an error.
>
> Found by Linux Verification Center (linuxtesting.org) with the SVACE
> static analysis tool.
> ---
>  src/shared/gatt-server.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/src/shared/gatt-server.c b/src/shared/gatt-server.c
> index 0e399ceb1..fb8819c70 100644
> --- a/src/shared/gatt-server.c
> +++ b/src/shared/gatt-server.c
> @@ -1822,6 +1822,7 @@ bool bt_gatt_server_send_notification(struct bt_gatt_server *server,
>         return result;
>
>  error:
> +       free(data->pdu);
>         if (data)
>                 free(data);

This should probably be inside if (data) block though.

>
> --
> 2.43.0
>
>


-- 
Luiz Augusto von Dentz

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

end of thread, other threads:[~2024-06-27 18:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-27 15:09 [PATCH BlueZ v1] gatt-server: fix memory leak in bt_gatt_server_send_notification() Roman Smirnov
2024-06-27 16:40 ` [BlueZ,v1] " bluez.test.bot
2024-06-27 18:31 ` [PATCH BlueZ v1] " Luiz Augusto von Dentz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox