Skip to content

Commit fd2ec58

Browse files
mishamyteclaude
andauthored
[SubGHz] Fix crash when exiting CLI subghz chat with external CC1101 (#1036)
* [SubGHz] Fix crash when exiting CLI `subghz chat` with external CC1101 Pressing Ctrl+C to exit `subghz chat` while using an external CC1101 crashed the Flipper (null-pointer dereference + reboot). The exit path called subghz_devices_deinit() before stopping the chat worker. deinit unloads the external CC1101 radio-device plugin, freeing its SubGhzDevice struct and interconnect vtable; the TxRx worker thread sleeps/ends that device from its own thread on shutdown, so joining it after deinit dereferenced freed plugin memory. The internal CC1101 is a static device that deinit never frees, which is why the crash was external-only. Stop and free the worker before subghz_devices_deinit(), matching the teardown order already used by subghz_cli_command_rx. Also add the missing deinit + radio power-off to the "tx not allowed" early return so a subsequent subghz command's subghz_devices_init() does not furi_check-fail on an already-valid registry. Fixes #829 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * changelog: SubGHz crash exiting CLI chat with external CC1101 (PR #1036, Fixes #829) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent e4e8a8e commit fd2ec58

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## Main changes
22
- Current API: 87.12
33
* SubGHz: **Fix endless TX causing RAW files to be transmitted and crash the system** (via RPC / Mobile App) (Fixes issue #1008)
4+
* SubGHz: **Fix crash when exiting CLI `subghz chat` with an external CC1101** - pressing Ctrl+C dereferenced the just-freed external CC1101 radio plugin during chat worker shutdown; internal CC1101 was unaffected (by @mishamyte | PR #1036 | Fixes #829)
45
* SubGHz: **Add Telcoma/Cardin EDGE protocol** (32bit, Static) (by @half2me | PR #1001)
56
* LFRFID: **Support of Hitag Micro chips** (8265/8210/H5.5) (by @mishamyte | PR #1002)
67
* LFRFID: **Wipe T5577** (reset to blank, with read-back verification) (by @mishamyte | PR #1003)

applications/main/subghz/subghz_cli.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -966,6 +966,8 @@ static void subghz_cli_command_chat(PipeSide* pipe, FuriString* args) {
966966
"In your settings, only reception on this frequency (%lu) is allowed,\r\n"
967967
"the actual operation of the application is not possible\r\n ",
968968
frequency);
969+
subghz_devices_deinit();
970+
subghz_cli_radio_device_power_off();
969971
return;
970972
}
971973

@@ -1113,16 +1115,19 @@ static void subghz_cli_command_chat(PipeSide* pipe, FuriString* args) {
11131115
furi_string_free(output);
11141116
furi_string_free(sysmsg);
11151117

1118+
// Stop the worker before deinit: its TxRx thread sleeps/ends the device on
1119+
// exit, and deinit frees that device when it's an external CC1101 plugin (UAF, #829).
1120+
if(subghz_chat_worker_is_running(subghz_chat)) {
1121+
subghz_chat_worker_stop(subghz_chat);
1122+
subghz_chat_worker_free(subghz_chat);
1123+
}
1124+
11161125
subghz_devices_deinit();
11171126
subghz_cli_radio_device_power_off();
11181127

11191128
furi_hal_power_suppress_charge_exit();
11201129
furi_record_close(RECORD_NOTIFICATION);
11211130

1122-
if(subghz_chat_worker_is_running(subghz_chat)) {
1123-
subghz_chat_worker_stop(subghz_chat);
1124-
subghz_chat_worker_free(subghz_chat);
1125-
}
11261131
printf("\r\nExit chat\r\n");
11271132
}
11281133

0 commit comments

Comments
 (0)