public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [BlueZ] obexd: Fix memory leak
@ 2024-05-16 13:40 Bastien Nocera
  2024-05-16 15:40 ` bluez.test.bot
  2024-05-17 14:50 ` patchwork-bot+bluetooth
  0 siblings, 2 replies; 3+ messages in thread
From: Bastien Nocera @ 2024-05-16 13:40 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Bastien Nocera

To not leak "buf", we need object->buffer to take ownership of it using
g_string_new_take() (but it's only available in 2.78 and newer), or we
need to actually free "buf".

Error: RESOURCE_LEAK (CWE-772): [#def66] [important]
bluez-5.75/obexd/plugins/filesystem.c:411:3: alloc_arg: "g_file_get_contents" allocates memory that is stored into "buf".
bluez-5.75/obexd/plugins/filesystem.c:418:3: noescape: Resource "buf" is not freed or pointed-to in "g_string_new".
bluez-5.75/obexd/plugins/filesystem.c:440:2: leaked_storage: Variable "buf" going out of scope leaks the storage it points to.
438|			*err = 0;
439|
440|->	return object;
441|
442|   fail:
---
 obexd/plugins/filesystem.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/obexd/plugins/filesystem.c b/obexd/plugins/filesystem.c
index f52927541bab..4887a0b8ac81 100644
--- a/obexd/plugins/filesystem.c
+++ b/obexd/plugins/filesystem.c
@@ -416,6 +416,7 @@ static void *capability_open(const char *name, int oflag, mode_t mode,
 		}
 
 		object->buffer = g_string_new(buf);
+		g_free(buf);
 
 		if (size)
 			*size = object->buffer->len;
-- 
2.44.0


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

* RE: [BlueZ] obexd: Fix memory leak
  2024-05-16 13:40 [BlueZ] obexd: Fix memory leak Bastien Nocera
@ 2024-05-16 15:40 ` bluez.test.bot
  2024-05-17 14:50 ` patchwork-bot+bluetooth
  1 sibling, 0 replies; 3+ messages in thread
From: bluez.test.bot @ 2024-05-16 15:40 UTC (permalink / raw)
  To: linux-bluetooth, hadess

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

---Test result---

Test Summary:
CheckPatch                    PASS      0.46 seconds
GitLint                       FAIL      0.51 seconds
BuildEll                      PASS      24.81 seconds
BluezMake                     PASS      1701.13 seconds
MakeCheck                     PASS      13.71 seconds
MakeDistcheck                 PASS      179.04 seconds
CheckValgrind                 PASS      250.72 seconds
CheckSmatch                   PASS      356.39 seconds
bluezmakeextell               PASS      120.95 seconds
IncrementalBuild              PASS      1481.59 seconds
ScanBuild                     PASS      1015.99 seconds

Details
##############################
Test: GitLint - FAIL
Desc: Run gitlint
Output:
[BlueZ] obexd: Fix memory leak

WARNING: I3 - ignore-body-lines: gitlint will be switching from using Python regex 'match' (match beginning) to 'search' (match anywhere) semantics. Please review your ignore-body-lines.regex option accordingly. To remove this warning, set general.regex-style-search=True. More details: https://jorisroovers.github.io/gitlint/configuration/#regex-style-search
8: B1 Line exceeds max length (121>80): "bluez-5.75/obexd/plugins/filesystem.c:411:3: alloc_arg: "g_file_get_contents" allocates memory that is stored into "buf"."
9: B1 Line exceeds max length (115>80): "bluez-5.75/obexd/plugins/filesystem.c:418:3: noescape: Resource "buf" is not freed or pointed-to in "g_string_new"."
10: B1 Line exceeds max length (126>80): "bluez-5.75/obexd/plugins/filesystem.c:440:2: leaked_storage: Variable "buf" going out of scope leaks the storage it points to."
11: B3 Line contains hard tab characters (\t): "438|			*err = 0;"
13: B3 Line contains hard tab characters (\t): "440|->	return object;"


---
Regards,
Linux Bluetooth


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

* Re: [BlueZ] obexd: Fix memory leak
  2024-05-16 13:40 [BlueZ] obexd: Fix memory leak Bastien Nocera
  2024-05-16 15:40 ` bluez.test.bot
@ 2024-05-17 14:50 ` patchwork-bot+bluetooth
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+bluetooth @ 2024-05-17 14:50 UTC (permalink / raw)
  To: Bastien Nocera; +Cc: linux-bluetooth

Hello:

This patch was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Thu, 16 May 2024 15:40:48 +0200 you wrote:
> To not leak "buf", we need object->buffer to take ownership of it using
> g_string_new_take() (but it's only available in 2.78 and newer), or we
> need to actually free "buf".
> 
> Error: RESOURCE_LEAK (CWE-772): [#def66] [important]
> bluez-5.75/obexd/plugins/filesystem.c:411:3: alloc_arg: "g_file_get_contents" allocates memory that is stored into "buf".
> bluez-5.75/obexd/plugins/filesystem.c:418:3: noescape: Resource "buf" is not freed or pointed-to in "g_string_new".
> bluez-5.75/obexd/plugins/filesystem.c:440:2: leaked_storage: Variable "buf" going out of scope leaks the storage it points to.
> 438|			*err = 0;
> 439|
> 440|->	return object;
> 441|
> 442|   fail:
> 
> [...]

Here is the summary with links:
  - [BlueZ] obexd: Fix memory leak
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=46c0e376fe13

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2024-05-17 14:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-16 13:40 [BlueZ] obexd: Fix memory leak Bastien Nocera
2024-05-16 15:40 ` bluez.test.bot
2024-05-17 14:50 ` patchwork-bot+bluetooth

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