Hi Gustavo, On Mon, Feb 20, 2012 at 3:33 PM, Gustavo Padovan <padovan@xxxxxxxxxxxxxx> wrote: > > Hi Andrei, > > * Emeltchenko Andrei <Andrei.Emeltchenko.news@xxxxxxxxx> [2012-02-20 16:21:13 +0200]: > > > From: Andrei Emeltchenko <andrei.emeltchenko@xxxxxxxxx> > > > > Usage of RCU list looks not reasonalbe for a number of reasons: > > our code sleep and we have to use socket spinlocks, some parts > > of code are updaters thus we need to use mutexes anyway. > > > > Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@xxxxxxxxx> > > --- > > net/bluetooth/l2cap_core.c | 165 ++++++++++++++++++++++++++------------------ > > net/bluetooth/l2cap_sock.c | 10 +++ > > 2 files changed, 108 insertions(+), 67 deletions(-)add an extra blank line here please. <snip> > > +unlock: > > + mutex_unlock(&conn->chan_lock); > > + > > + return err; > > } > > > > static inline void set_default_fcs(struct l2cap_chan *chan) > > @@ -2793,6 +2804,7 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr > > return -ENOENT; > > > > sk = chan->sk; > > + lock_sock(sk); > > > > if (chan->state != BT_CONFIG && chan->state != BT_CONNECT2) { > > struct l2cap_cmd_rej_cid rej; > > @@ -2905,6 +2917,7 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr > > return 0; > > > > sk = chan->sk; > > + lock_sock(sk); > > > > switch (result) { > > case L2CAP_CONF_SUCCESS: > > @@ -3006,11 +3019,16 @@ static inline int l2cap_disconnect_req(struct l2cap_conn *conn, struct l2cap_cmd > > > > BT_DBG("scid 0x%4.4x dcid 0x%4.4x", scid, dcid); > > > > - chan = l2cap_get_chan_by_scid(conn, dcid); > > - if (!chan) > > + mutex_lock(&conn->chan_lock); > > + > > + chan = __l2cap_get_chan_by_scid(conn, dcid); > > + if (!chan) { > > + mutex_unlock(&conn->chan_lock); > > return 0; > > Seems to me we can use l2cap_get_chan_by_scid() here. It's better if we don't as we'll call l2cap_chan_del() which might remove chan from conn->chan_l that's protected by conn->chan_lock. Let's leave it as he sent. > > + } > > > > sk = chan->sk; > > + lock_sock(sk); > > > > rsp.dcid = cpu_to_le16(chan->scid); > > rsp.scid = cpu_to_le16(chan->dcid); > > @@ -3022,6 +3040,9 @@ static inline int l2cap_disconnect_req(struct l2cap_conn *conn, struct l2cap_cmd > > release_sock(sk); > > > > chan->ops->close(chan->data); > > + > > + mutex_unlock(&conn->chan_lock); > > + > > return 0; > > } > > > > @@ -3037,16 +3058,24 @@ static inline int l2cap_disconnect_rsp(struct l2cap_conn *conn, struct l2cap_cmd > > > > BT_DBG("dcid 0x%4.4x scid 0x%4.4x", dcid, scid); > > > > - chan = l2cap_get_chan_by_scid(conn, scid); > > - if (!chan) > > + mutex_lock(&conn->chan_lock); > > + > > + chan = __l2cap_get_chan_by_scid(conn, scid); > > + if (!chan) { > > + mutex_unlock(&conn->chan_lock); > > return 0; > > Same here. Same comment above applies here. Apart from the extra new line that Padovan asked I'm ok with this commit. Reviewed-by: Ulisses Furquim <ulisses@xxxxxxxxxxxxxx> Regards, -- Ulisses Furquim ProFUSION embedded systems http://profusion.mobi Mobile: +55 19 9250 0942 Skype: ulissesffs -- To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html