Skip to content

RDKOSS-899 : DO NOT MERGE - bluezChk-RDKC - #62

Open
PreethiLakshmi91 wants to merge 1 commit into
developfrom
RDKOSS-899
Open

RDKOSS-899 : DO NOT MERGE - bluezChk-RDKC#62
PreethiLakshmi91 wants to merge 1 commit into
developfrom
RDKOSS-899

Conversation

@PreethiLakshmi91

Copy link
Copy Markdown
Contributor

Reason for change: Inclusion of coverity for BT
Test Procedure: NA
Risks: Low
Priority: P2

Reason for change: Inclusion of coverity for BT
Test Procedure: NA
Risks: Low
Priority: P2

Signed-off-by: ppalan289 <preethi_palanisamy@comcast.com>
@PreethiLakshmi91
PreethiLakshmi91 requested a review from a team as a code owner April 21, 2026 09:26
Copilot AI review requested due to automatic review settings April 21, 2026 09:26
@PreethiLakshmi91
PreethiLakshmi91 requested a review from a team as a code owner April 21, 2026 09:26

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a BlueZ source patch intended to introduce known defects (resource leak + null dereference) so Coverity can detect them, and wires that patch into the bluez5_5.48 Yocto recipe via SRC_URI.

Changes:

  • Introduces a new BlueZ patch that intentionally leaks memory and performs a NULL-dereference pattern.
  • Applies the new patch unconditionally by adding it to SRC_URI in the bluez5_5.48 .bbappend.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
recipes-connectivity/bluez5/bluez5_5.48/bluez-5.48-071-RDKOSS-899-bluez-for-coverity-check.patch Injects intentional Coverity-detectable defects into gdbus/watch.c (add_match).
recipes-connectivity/bluez5/bluez5_5.48.bbappend Adds the new patch to SRC_URI, causing it to apply during normal builds.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +5 to +30
@@ -166,6 +166,20 @@ static gboolean add_match(struct filter_data *data,
{
DBusError err;
char rule[DBUS_MAXIMUM_MATCH_RULE_LENGTH];
+ char *coverity_test_buf;
+
+ /* Intentionally allocate memory and do not free it on all paths
+ * Used to validate Coverity RESOURCE_LEAK detection
+ */
+ coverity_test_buf = g_new0(char, 16);
+
+ /* Intentionally introduce NULL dereference before NULL check
+ * Used to validate Coverity NULL_DEREFERENCE detection
+ */
+ coverity_test_buf[0] = 'C';
+
+ if (coverity_test_buf == NULL)
+ return FALSE;

format_rule(data, rule, sizeof(rule));
dbus_error_init(&err);
@@ -178,6 +192,7 @@ static gboolean add_match(struct filter_data *data,
return FALSE;
}

+ /* coverity_test_buf intentionally not freed */

Copilot AI Apr 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This patch intentionally introduces a NULL dereference (dereferencing coverity_test_buf before checking for NULL) and an unconditional memory leak. Even if meant for Coverity validation, including this in the BlueZ source applied by the recipe can cause real runtime crashes under low-memory conditions and degrades code quality. Please avoid shipping intentional defects: either remove this patch from the normal build, or guard the injected code behind a compile-time flag and only enable/apply it in a dedicated Coverity-only build configuration (e.g., conditional SRC_URI based on a DISTRO_FEATURE/PACKAGECONFIG/override).

Suggested change
@@ -166,6 +166,20 @@ static gboolean add_match(struct filter_data *data,
{
DBusError err;
char rule[DBUS_MAXIMUM_MATCH_RULE_LENGTH];
+ char *coverity_test_buf;
+
+ /* Intentionally allocate memory and do not free it on all paths
+ * Used to validate Coverity RESOURCE_LEAK detection
+ */
+ coverity_test_buf = g_new0(char, 16);
+
+ /* Intentionally introduce NULL dereference before NULL check
+ * Used to validate Coverity NULL_DEREFERENCE detection
+ */
+ coverity_test_buf[0] = 'C';
+
+ if (coverity_test_buf == NULL)
+ return FALSE;
format_rule(data, rule, sizeof(rule));
dbus_error_init(&err);
@@ -178,6 +192,7 @@ static gboolean add_match(struct filter_data *data,
return FALSE;
}
+ /* coverity_test_buf intentionally not freed */
@@ -166,6 +166,6 @@ static gboolean add_match(struct filter_data *data,
{
DBusError err;
char rule[DBUS_MAXIMUM_MATCH_RULE_LENGTH];
format_rule(data, rule, sizeof(rule));
dbus_error_init(&err);
@@ -178,6 +178,6 @@ static gboolean add_match(struct filter_data *data,
return FALSE;
}

Copilot uses AI. Check for mistakes.
Comment on lines +63 to 65
file://bluez-5.48-071-RDKOSS-899-bluez-for-coverity-check.patch \
"

Copilot AI Apr 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding this patch to SRC_URI makes the intentional crash/leak injection apply to all builds of bluez5_5.48, not just Coverity runs. If the goal is to validate Coverity, please make this patch conditional (e.g., using bb.utils.contains on a dedicated DISTRO_FEATURE like 'coverity', or a recipe override) so production images are unaffected, or keep it out of this layer entirely.

Suggested change
file://bluez-5.48-071-RDKOSS-899-bluez-for-coverity-check.patch \
"
"
SRC_URI:append = "${@bb.utils.contains('DISTRO_FEATURES', 'coverity', ' file://bluez-5.48-071-RDKOSS-899-bluez-for-coverity-check.patch', '', d)}"

Copilot uses AI. Check for mistakes.
file://bluez-5.48-068-RDKOSS-553-stream-use-after-free.patch \
file://bluez-5.48-069-RDKEMW-11885-UAF-in-messagefilter.patch \
file://bluez-5.48-070-ES1-2351-remove-corrupted-hog.patch \
file://bluez-5.48-071-RDKOSS-899-bluez-for-coverity-check.patch \

Copilot AI Apr 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR description states "Risks: Low", but this change introduces an intentional NULL dereference and memory leak into BlueZ for all builds (via SRC_URI). Unless this is strictly gated to Coverity-only builds, the operational risk is high (potential crash under OOM). Please update the PR description risk assessment or change the implementation to ensure production builds are unaffected.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants