From: Marcel Holtmann <marcel@holtmann.org>
To: Mat Martineau <mathewm@codeaurora.org>
Cc: linux-bluetooth@vger.kernel.org, gustavo@padovan.org,
pkrystad@codeaurora.org
Subject: Re: [PATCH 1/2] Bluetooth: Fix early return from l2cap_chan_del
Date: Thu, 17 May 2012 19:30:24 -0700 [thread overview]
Message-ID: <1337308224.5970.280.camel@aeonflux> (raw)
In-Reply-To: <1337296814-3763-2-git-send-email-mathewm@codeaurora.org>
Hi Mat,
> This fixes a regression from commit
> 2ead70b8390d199ca04cd35311b51f5f3676079e that is present in all
> kernels starting at v3.0.
>
> When L2CAP information was moved to struct l2cap_chan, a check was
> added to l2cap_chan_del to avoid certain cleanup operations when ERTM
> or streaming mode had not yet been initialized. The logic in the
> check did not take in to account that chan->conf_state is set to 0 in
> l2cap_chan_ready, so l2cap_chan_del failed to cancel timers and leaked
> memory any time the ERTM queues or lists were not empty.
>
> This change makes sure that l2cap_chan_del only returns early if
> ERTM initialization was not performed.
>
> Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
> ---
> include/net/bluetooth/l2cap.h | 1 +
> net/bluetooth/l2cap_core.c | 4 ++--
> 2 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
> index 1c7d1cd..452fcc4 100644
> --- a/include/net/bluetooth/l2cap.h
> +++ b/include/net/bluetooth/l2cap.h
> @@ -597,6 +597,7 @@ enum {
> CONF_EWS_RECV,
> CONF_LOC_CONF_PEND,
> CONF_REM_CONF_PEND,
> + CONF_NOT_COMPLETE,
> };
>
> #define L2CAP_CONF_MAX_CONF_REQ 2
> diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
> index 24f144b..36edd42 100644
> --- a/net/bluetooth/l2cap_core.c
> +++ b/net/bluetooth/l2cap_core.c
> @@ -391,6 +391,7 @@ struct l2cap_chan *l2cap_chan_create(void)
> chan->state = BT_OPEN;
>
> atomic_set(&chan->refcnt, 1);
> + set_bit(CONF_NOT_COMPLETE, &chan->conf_state);
>
> BT_DBG("chan %p", chan);
>
> @@ -509,8 +510,7 @@ static void l2cap_chan_del(struct l2cap_chan *chan, int err)
>
> release_sock(sk);
>
> - if (!(test_bit(CONF_OUTPUT_DONE, &chan->conf_state) &&
> - test_bit(CONF_INPUT_DONE, &chan->conf_state)))
> + if (test_bit(CONF_NOT_COMPLETE, &chan->conf_state))
> return;
explain to me how this works? We never clear that bit.
Regards
Marcel
next prev parent reply other threads:[~2012-05-18 2:30 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-17 23:20 [PATCH 0/2] l2cap_chan init and delete fixes for ERTM Mat Martineau
2012-05-17 23:20 ` [PATCH 1/2] Bluetooth: Fix early return from l2cap_chan_del Mat Martineau
2012-05-18 2:30 ` Marcel Holtmann [this message]
2012-05-18 3:29 ` Mat Martineau
2012-05-18 3:30 ` Marcel Holtmann
2012-05-17 23:20 ` [PATCH 2/2] Bluetooth: Free allocated ERTM SREJ list if init fails Mat Martineau
2012-05-18 2:31 ` Marcel Holtmann
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=1337308224.5970.280.camel@aeonflux \
--to=marcel@holtmann.org \
--cc=gustavo@padovan.org \
--cc=linux-bluetooth@vger.kernel.org \
--cc=mathewm@codeaurora.org \
--cc=pkrystad@codeaurora.org \
/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;
as well as URLs for NNTP newsgroup(s).