Skip to content

Conversation

cvinayak
Copy link
Contributor

@cvinayak cvinayak commented Oct 21, 2025

Fix use-after-release in lll_scan/lll_scan_aux when using mayfly_enqueue to defer execution of the offset calculation using ull_sched_mfy_after_cen_offset_get().

Fixes #97967.

@cvinayak cvinayak requested a review from Copilot October 21, 2025 20:31
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a use-after-release bug in the Bluetooth controller's scanning functionality when using deferred execution for offset calculations. The issue occurs when a prepare parameter passed to mayfly_enqueue goes out of scope before the deferred callback executes.

  • Adds persistent storage for prepare parameters in the lll_scan structure
  • Copies required values from stack-allocated parameters to the persistent storage before enqueueing
  • Updates variable naming for consistency (retvalret)

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
subsys/bluetooth/controller/ll_sw/lll_scan.h Adds prepare_param field to lll_scan struct under CONFIG_BT_CTLR_SCHED_ADVANCED
subsys/bluetooth/controller/ll_sw/nordic/lll/lll_scan_aux.c Copies prepare parameters to persistent storage before mayfly enqueue
subsys/bluetooth/controller/ll_sw/nordic/lll/lll_scan.c Copies prepare parameters to persistent storage and fixes variable naming

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

carlescufi
carlescufi previously approved these changes Oct 23, 2025
Fix use-after-release in lll_scan/lll_scan_aux when using
mayfly_enqueue to defer execution of the offset calculation
using ull_sched_mfy_after_cen_offset_get().

Apply suggestion from @Copilot

Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
@sonarqubecloud
Copy link

@cvinayak cvinayak requested a review from aescolar October 23, 2025 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: Bluetooth Controller area: Bluetooth bug The issue is a bug, or the PR is fixing a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bluetooth: Controller: Use-after-release of lll_event in mayfly_enqueue path in lll_scan.c/lll_scan_aux.c

3 participants