From: Dominique MARTINET <dominique.martinet@atmark-techno.com>
To: Neeraj Sanjay Kale <neeraj.sanjaykale@nxp.com>
Cc: marcel@holtmann.org, luiz.dentz@gmail.com,
linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org,
amitkumar.karwar@nxp.com, rohit.fule@nxp.com, sherry.sun@nxp.com,
ziniu.wang_1@nxp.com, haibo.chen@nxp.com, LnxRevLi@nxp.com,
guillaume.legoupil@nxp.com, salim.chebbo@nxp.com
Subject: Re: [PATCH v1 1/3] Bluetooth: btnxpuart: Fix Null pointer dereference in btnxpuart_flush()
Date: Tue, 18 Mar 2025 08:51:11 +0900 [thread overview]
Message-ID: <Z9i1b9hzZzwJnIYh@atmark-techno.com> (raw)
In-Reply-To: <20240515070657.85132-2-neeraj.sanjaykale@nxp.com>
Hi,
Neeraj Sanjay Kale wrote on Wed, May 15, 2024 at 12:36:55PM +0530:
> @@ -1269,8 +1271,10 @@ static int btnxpuart_flush(struct hci_dev *hdev)
>
> cancel_work_sync(&nxpdev->tx_work);
>
> - kfree_skb(nxpdev->rx_skb);
> - nxpdev->rx_skb = NULL;
> + if (!IS_ERR_OR_NULL(nxpdev->rx_skb)) {
> + kfree_skb(nxpdev->rx_skb);
> + nxpdev->rx_skb = NULL;
> + }
This is an old patch but I hit that on our slightly old tree and was
wondering about this patch: why does flush() have to free rx at all?
I think this either needs a lock or (preferably) just remove this free:
- This is inherently racy with btnxpuart_receive_buf() which is run in
another workqueue with no lock involved as far as I understand, so this
is not just about errors but you could also free something in a weird
place here.
As far as I understand, even if we don't do anything, the rx path will
free the reply if no matching request was found.
- looking at other drivers, the hdev->flush() call never does anything
about rx and seems to only be about rx
(ah, checking again as of master drivers/bluetooth/btmtkuart.c seems to
have this same problem as of before this patch e.g. they're not checking
for errors either... This probably needs something akin to this patch or
removal as well. All other drivers have flush seem to be mostly about
tx, but I do see some cancel work for rx as well so I'm a bit unclear as
to what is expected of flush())
Thank you,
--
Dominique
next prev parent reply other threads:[~2025-03-18 0:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-15 7:06 [PATCH v1 0/3] Enable status prints for firmware download Neeraj Sanjay Kale
2024-05-15 7:06 ` [PATCH v1 1/3] Bluetooth: btnxpuart: Fix Null pointer dereference in btnxpuart_flush() Neeraj Sanjay Kale
2024-05-15 7:33 ` Enable status prints for firmware download bluez.test.bot
2025-03-17 23:51 ` Dominique MARTINET [this message]
2025-03-20 10:20 ` [PATCH v1 1/3] Bluetooth: btnxpuart: Fix Null pointer dereference in btnxpuart_flush() Neeraj Sanjay Kale
2024-05-15 7:06 ` [PATCH v1 2/3] Bluetooth: btnxpuart: Enable status prints for firmware download Neeraj Sanjay Kale
2024-05-15 7:06 ` [PATCH v1 3/3] Bluetooth: btnxpuart: Handle FW Download Abort scenario Neeraj Sanjay Kale
2024-05-15 20:00 ` [PATCH v1 0/3] Enable status prints for firmware download 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=Z9i1b9hzZzwJnIYh@atmark-techno.com \
--to=dominique.martinet@atmark-techno.com \
--cc=LnxRevLi@nxp.com \
--cc=amitkumar.karwar@nxp.com \
--cc=guillaume.legoupil@nxp.com \
--cc=haibo.chen@nxp.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
--cc=marcel@holtmann.org \
--cc=neeraj.sanjaykale@nxp.com \
--cc=rohit.fule@nxp.com \
--cc=salim.chebbo@nxp.com \
--cc=sherry.sun@nxp.com \
--cc=ziniu.wang_1@nxp.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