mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Artur <arturfaleiros1254@gmail.com>
To: Marcel Holtmann <marcel@holtmann.org>,
	Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Cc: Max Chou <max.chou@realtek.com>,
	linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org,
	Artur <arturfaleiros1254@gmail.com>
Subject: [PATCH 0/2] Bluetooth: btrtl: Don't return NULL from btrtl_initialize()
Date: Sun, 15 Nov 2026 19:53:11 +0000	[thread overview]
Message-ID: <20261115195313.20809-1-arturfaleiros1254@gmail.com> (raw)

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


             reply	other threads:[~2026-11-15 19:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-15 19:53 Artur [this message]
2026-11-15 19:53 ` [PATCH 1/2] Bluetooth: btrtl: Return an error when reading the key id fails Artur
2026-11-15 19:53 ` [PATCH 2/2] Bluetooth: btrtl: Set an error code when skb allocation fails Artur
2026-11-19 18:50 ` [PATCH 0/2] Bluetooth: btrtl: Don't return NULL from btrtl_initialize() patchwork-bot+bluetooth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261115195313.20809-1-arturfaleiros1254@gmail.com \
    --to=arturfaleiros1254@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    --cc=marcel@holtmann.org \
    --cc=max.chou@realtek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®