[PATCH 0/2] Bluetooth: btrtl: Don't return NULL from btrtl_initialize()
From: Artur
Date: Sun Nov 15 2026 - 14:53:40 EST
btrtl_initialize() has two error paths that jump to err_free while
'ret' is still 0, so the function returns ERR_PTR(0), which is NULL.
Both callers only check the result with IS_ERR() and then dereference
the pointer.
Patch 1 fixes the path taken when reading the RTL_SEC_PROJ register
fails. It can be hit by a controller that times out or answers the
vendor command with an error during setup.
Patch 2 fixes the path taken when allocating the skb for the drop
firmware vendor command fails.
The two bugs come from different commits, so they are fixed in
separate patches with their own Fixes: tags.
Testing: compile tested only, on x86_64 against mainline commit
fa2933aac170 (after v7.4-rc2), with W=1 and sparse, without new
warnings. smatch no longer reports "passing zero to 'ERR_PTR'" in
btrtl_initialize() after patch 2. The error paths have not been
exercised at runtime: no Realtek Bluetooth controller was available
and no reproducer was written. drivers/bluetooth/btrtl.c is identical
in bluetooth-next, so the series applies there as well.
The bugs were found with smatch while checking the Bluetooth USB
drivers. The analysis, the fixes and the descriptions were prepared
with the help of an AI coding assistant (Claude Opus 5.5).
Artur (2):
Bluetooth: btrtl: Return an error when reading the key id fails
Bluetooth: btrtl: Set an error code when skb allocation fails
drivers/bluetooth/btrtl.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
base-commit: fa2933aac170dd19c6a7f0d7b81a8f537e40915c
--
2.43.0