From: Paolo Abeni <pabeni@redhat.com>
To: Jianglei Nie <niejianglei2021@163.com>,
marcel@holtmann.org, johan.hedberg@gmail.com,
luiz.dentz@gmail.com, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org
Cc: linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Bluetooth: hci_conn: fix potential double free in le_scan_cleanup()
Date: Thu, 26 May 2022 13:24:32 +0200 [thread overview]
Message-ID: <081b216e6496e8cc2284df191dcc2d8b604d04f7.camel@redhat.com> (raw)
In-Reply-To: <20220526094918.482971-1-niejianglei2021@163.com>
On Thu, 2022-05-26 at 17:49 +0800, Jianglei Nie wrote:
> When "c == conn" is true, hci_conn_cleanup() is called. The
> hci_conn_cleanup() calls hci_dev_put() and hci_conn_put() in
> its function implementation. hci_dev_put() and hci_conn_put()
> will free the relevant resource if the reference count reaches
> zero, which may lead to a double free when hci_dev_put() and
> hci_conn_put() are called again.
>
> We should add a return to this function after hci_conn_cleanup()
> is called.
>
> Signed-off-by: Jianglei Nie <niejianglei2021@163.com>
> ---
> net/bluetooth/hci_conn.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
> index fe803bee419a..7b3e91eb9fa3 100644
> --- a/net/bluetooth/hci_conn.c
> +++ b/net/bluetooth/hci_conn.c
> @@ -166,6 +166,7 @@ static void le_scan_cleanup(struct work_struct *work)
> if (c == conn) {
> hci_connect_le_scan_cleanup(conn);
> hci_conn_cleanup(conn);
> + return;
This looks not correct. At very least you should release the
hci_dev_lock.
Cheers,
Paolo
next prev parent reply other threads:[~2022-05-26 11:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-26 9:49 [PATCH] Bluetooth: hci_conn: fix potential double free in le_scan_cleanup() Jianglei Nie
2022-05-26 11:24 ` Paolo Abeni [this message]
2022-05-26 20:11 ` Luiz Augusto von Dentz
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=081b216e6496e8cc2284df191dcc2d8b604d04f7.camel@redhat.com \
--to=pabeni@redhat.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=johan.hedberg@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
--cc=marcel@holtmann.org \
--cc=netdev@vger.kernel.org \
--cc=niejianglei2021@163.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