Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Thomas Gerner" <thomas.gerner@muenchen-mail.de>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH 2/2] Bluetooth: btbcm: disable read tx power for BeagleV-Ahead
Date: Sun, 11 Oct 2026 13:46:46 +0000	[thread overview]
Message-ID: <sashiko-outbox-167275@kernel.org> (raw)
In-Reply-To: <578087018e274b0dcf25a523adc0d5cc590cceee.1791720467.git.thomas.gerner@muenchen-mail.de>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] bluetooth: btbcm: devm_kstrdup memory leak of board string on repeated initialization
--

commit d78be9f56325d78f88a3903ffe62866de6e22e52
Author: Thomas Gerner <thomas.gerner@muenchen-mail.de>

Bluetooth: btbcm: disable read tx power for BeagleV-Ahead

The bluetooth module on the BeagleV-Ahead reports LE tx power read
capabilities but fails when actually doing it. This patch adds a quirk to
disable this reading based on the board's compatible string from the DTB.

> diff --git a/drivers/bluetooth/btbcm.c b/drivers/bluetooth/btbcm.c
> index 463d59890befe..2d02cc1863d0b 100644
> --- a/drivers/bluetooth/btbcm.c
> +++ b/drivers/bluetooth/btbcm.c
[ ... ]
> @@ -537,12 +542,13 @@ static const struct bcm_subver_table bcm_usb_subver_table[] = {
>   * This currently only looks up the device tree board appendix,
>   * but can be expanded to other mechanisms.
>   */
> -static const char *btbcm_get_board_name(struct device *dev)
> +static const char *btbcm_get_board_name(struct hci_dev *hdev)
>  {
>  #ifdef CONFIG_OF
>  	struct device_node *root __free(device_node) = of_find_node_by_path("/");
>  	char *board_type;
>  	const char *tmp;
> +	const char **s;
>  
>  	if (!root)
>  		return NULL;
> @@ -550,8 +556,15 @@ static const char *btbcm_get_board_name(struct device *dev)
>  	if (of_property_read_string_index(root, "compatible", 0, &tmp))
>  		return NULL;
>  
> +	/* disable broken Read LE Min/Max Tx Power on first board found in list */
> +	for (s = board_broken_read_transmit_power; *s; s++)
> +		if (!strcmp(tmp, *s)) {
> +			hci_set_quirk(hdev, HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER);
> +			break;
> +		}
> +
>  	/* get rid of any '/' in the compatible string */
> -	board_type = devm_kstrdup(dev, tmp, GFP_KERNEL);
> +	board_type = devm_kstrdup(&hdev->dev, tmp, GFP_KERNEL);

[Severity: Low]
Can this leak the board string on repeated initialization?

During device setup, btbcm_setup_patchram() calls btbcm_initialize(), which
calls btbcm_get_board_name(). The board_type string is allocated using
devm_kstrdup() and returned, but it is only stored locally as board_name in
btbcm_initialize() and discarded when the function returns.

Since btbcm_setup_patchram() subsequently calls btbcm_finalize(), which will
invoke btbcm_initialize() a second time if the firmware was successfully
loaded, the devm_kstrdup() allocation happens again, adding another permanent
entry to the devres list.

Could kstrdup() be used instead so the memory can be explicitly freed when it
is no longer needed?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1791720467.git.thomas.gerner@muenchen-mail.de?part=2

  reply	other threads:[~2026-10-11 13:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-11 13:37 [PATCH 0/2] Enable bluetooth on BeagleV-Ahead Thomas Gerner
2026-10-11 13:37 ` [PATCH 2/2] Bluetooth: btbcm: disable read tx power for BeagleV-Ahead Thomas Gerner
2026-10-11 13:46   ` sashiko-bot [this message]
2026-10-11 13:37 ` [PATCH 1/2] riscv: dts: thead: Enable bluetooth on BeagleV-Ahead Thomas Gerner
2026-10-11 13:48   ` sashiko-bot

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=sashiko-outbox-167275@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=thomas.gerner@muenchen-mail.de \
    /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