Skip to content

Bluetooth: btrtl: Fix NULL return on errors in btrtl_initialize()

Tzung-Bi Shih linux-bluetooth lkml stable 2 versions – Applied

Status from this message: This series was applied to bluetooth/bluetooth-next.git (master)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 1 replyApplied 2/2
  2. v12 patches 2 repliesSuperseded

Changes in v2 from the cover letter

- Rebase to next-20261118.

Patches in v2 All 2 applied

#Subject and filesSizeRepliesApplied
1/2Bluetooth: btrtl: Propagate errors if btrtl_vendor_read_reg16() failsdrivers/bluetooth/btrtl.c+2 -31 replyApplied
2/2Bluetooth: btrtl: Return -ENOMEM if bt_skb_alloc() failsdrivers/bluetooth/btrtl.c+3 -10 repliesApplied

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/2] Bluetooth: btrtl: Fix NULL return on errors in btrtl_initialize()

In btrtl_initialize(), the err_free error path frees btrtl_dev and returns ERR_PTR(ret). Because earlier calls in btrtl_initialize() set ret to 0 on success, any subsequent failure path that jumps to err_free without setting ret to a negative error code causes btrtl_initialize() to return ERR_PTR(0) (NULL).

Since the caller btrtl_setup_realtek() only checks IS_ERR(btrtl_dev), a NULL return bypasses the error check and causes a NULL pointer dereference in btrtl_download_firmware().

- Patch 1 fixes a NULL pointer dereference observed when btrtl_vendor_read_reg16() fails.
- Patch 2 fixes a similar issue found by inspection when bt_skb_alloc() fails.

---
v2:
- Rebase to next-20261118.

v1: https://lore.kernel.org/all/[email protected]

Tzung-Bi Shih (2):
Bluetooth: btrtl: Propagate errors if btrtl_vendor_read_reg16() fails
Bluetooth: btrtl: Return -ENOMEM if bt_skb_alloc() fails

 drivers/bluetooth/btrtl.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
Signature · 1 line
2.56.1.708.g77570a6a1d-goog