diff mbox series

[BlueZ,v1] gatt-server: fix memory leak in bt_gatt_server_send_notification()

Message ID 20240627150917.85755-1-r.smirnov@omp.ru (mailing list archive)
State Superseded
Headers show
Series [BlueZ,v1] gatt-server: fix memory leak in bt_gatt_server_send_notification() | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/CheckPatch success CheckPatch PASS
tedd_an/GitLint success Gitlint PASS
tedd_an/BuildEll success Build ELL PASS
tedd_an/BluezMake success Bluez Make PASS
tedd_an/MakeCheck success Bluez Make Check PASS
tedd_an/MakeDistcheck success Make Distcheck PASS
tedd_an/CheckValgrind success Check Valgrind PASS
tedd_an/CheckSmatch warning CheckSparse WARNING 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.
tedd_an/bluezmakeextell success Make External ELL PASS
tedd_an/IncrementalBuild success Incremental Build PASS
tedd_an/ScanBuild success Scan Build PASS

Commit Message

Roman Smirnov June 27, 2024, 3:09 p.m. UTC
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(+)

Comments

bluez.test.bot@gmail.com June 27, 2024, 4:40 p.m. UTC | #1
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
Luiz Augusto von Dentz June 27, 2024, 6:31 p.m. UTC | #2
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
>
>
diff mbox series

Patch

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);