Re: [PATCH] Bluetooth: HIDP: guard session->conn in hidp_connection_del
From: Pauli Virtanen
Date: Wed Apr 22 2026 - 11:48:49 EST
Hi,
ke, 2026-04-22 kello 11:09 -0400, Michael Bommarito kirjoitti:
> On Wed, Apr 22, 2026 at 10:55 AM Luiz Augusto von Dentz
> <luiz.dentz@xxxxxxxxx> wrote:
> > We might need a lock in order to access the session->conn:
>
> This one is a little easier than the other txwin_size issue in terms
> of blast radius.
>
> What pattern would you prefer here?
>
> Option 1, smaller but ordering questions: hold the semaphore across
> check and use like this:
>
> down_read(&hidp_session_sem);
> if (session->conn)
> l2cap_unregister_user(session->conn, &session->user);
> up_read(&hidp_session_sem)
>
>
> Option 2, more correct but more cycles: snapshot the conn and use outside
>
> down_read(&hidp_session_sem);
> conn = session->conn;
> if (conn)
> l2cap_conn_get(conn);
> up_read(&hidp_session_sem);
> if (conn) {
> l2cap_unregister_user(conn, &session->user);
> l2cap_conn_put(conn);
> }
I'm not sure now (would need to rethink it through), but one probably
should check if dbf666e4fc9b is needed or whether 752a6c9596d alone
would be enough to address the original issue.
--
Pauli Virtanen