Re: [PATCH] Bluetooth: HIDP: guard session->conn in hidp_connection_del

From: Michael Bommarito

Date: Wed Apr 22 2026 - 11:15:40 EST


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);
}

Thanks,
Mike Bommarito