Skip to contentSkip to conversation

obexd: Fix FILE* leak in phonebook-dummy

PATCH In review Jinwang Li 2 participants 3 messages Sep 30 – Oct 15 Bluetooth drivers

lore
Share & tools
lore

Jinwang Li

author
#0 lore raw

PATCH 1/1 obexd: Fix FILE* leak in phonebook-dummy

fdopen(fd, "r") transfers ownership of fd to the FILE stream, but the loop was calling close(fd) directly instead of fclose(fp), leaking the FILE structure and its stdio buffer on every vCard read. Also handle fdopen() failure, which was previously unchecked.

---
 obexd/plugins/phonebook-dummy.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
obexd/plugins/phonebook-dummy.c +8 -1
index f308ea701..43be956a5 100644
@@ -164,6 +164,13 @@ static int foreach_vcard(DIR *dp, vcard_func_t func, uint16_t offset,
 		}
 
 		fp = fdopen(fd, "r");
+		if (fp == NULL) {
+			err = errno;
+			error("fdopen(%s): %s(%d)", filename, strerror(err), err);
+			close(fd);
+			continue;
+		}
+
 		v = Parse_MIME_FromFile(fp);
 		if (v != NULL) {
 			func(filename, v, user_data);
@@ -171,7 +178,7 @@ static int foreach_vcard(DIR *dp, vcard_func_t func, uint16_t offset,
 			n++;
 		}
 
-		close(fd);
+		fclose(fp);
 	}
 
 	g_slist_free_full(sorted, g_free);
Signature · 1 line
2.34.1
#1 lore raw

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/series/1176647/

---Test result---

Test Summary:

CheckPatch                    FAIL      0.36 seconds
GitLint                       PASS      0.22 seconds
BuildEll                      PASS      19.90 seconds
BluezMake                     PASS      386.30 seconds
CheckSmatch                   PASS      295.83 seconds
bluezmakeextell               PASS      95.06 seconds
TestFunctional                PASS      1128.28 seconds
IncrementalBuild              PASS      403.49 seconds
ScanBuild                     PASS      1123.46 seconds

Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script
Output:
[v1] obexd: Fix FILE* leak in phonebook-dummy WARNING:LONG_LINE: line length of 82 exceeds 80 columns #129: FILE: obexd/plugins/phonebook-dummy.c:169:
+ error("fdopen(%s): %s(%d)", filename, strerror(err), err);

/home/runner/work/bluez/bluez/src/patch/14857371.patch total: 0 errors, 1 warnings, 21 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.

/home/runner/work/bluez/bluez/src/patch/14857371.patch has style problems, please review.

NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO

NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.

https://github.com/bluez/bluez/pull/2611

---
Regards,
Linux Bluetooth

#2 lore raw
In reply to Jinwang Li

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

Dear Submitter,

This series was picked up by the CI more than 2 weeks ago and the pull request created for it is still open, which means the series was never applied to the tree.

Series: [v1] obexd: Fix FILE* leak in phonebook-dummy
Pull Request: https://github.com/bluez/bluez/pull/2611
Created: 2026-09-30 14:09:52+00:00

The pull request has been closed and no further action is taken on this series.

If the change should still be considered, it must be resent to the Linux Bluetooth mailing list ([email protected]) so that it is picked up again.

---
Regards,
Linux Bluetooth