diff options
| author | Jakub Kicinski <[email protected]> | 2025-02-13 20:43:01 +0000 |
|---|---|---|
| committer | Jakub Kicinski <[email protected]> | 2025-02-13 20:43:30 +0000 |
| commit | 7a7e0197133d18cfd9931e7d3a842d0f5730223f (patch) | |
| tree | b9e558f5cbc5e4bec8c32b37e4168976f52f6cc7 /net/bluetooth/l2cap_sock.c | |
| parent | net: usb: asix_devices: add FiberGecko DeviceID (diff) | |
| parent | Merge tag 'net-6.14-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/net... (diff) | |
| download | kernel-7a7e0197133d18cfd9931e7d3a842d0f5730223f.tar.gz kernel-7a7e0197133d18cfd9931e7d3a842d0f5730223f.zip | |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
Cross-merge networking fixes after downstream PR (net-6.14-rc3).
No conflicts or adjacent changes.
Signed-off-by: Jakub Kicinski <[email protected]>
Diffstat (limited to 'net/bluetooth/l2cap_sock.c')
| -rw-r--r-- | net/bluetooth/l2cap_sock.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index 46ea0bee2259..acd11b268b98 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c @@ -1326,9 +1326,10 @@ static int l2cap_sock_shutdown(struct socket *sock, int how) /* prevent sk structure from being freed whilst unlocked */ sock_hold(sk); - chan = l2cap_pi(sk)->chan; /* prevent chan structure from being freed whilst unlocked */ - l2cap_chan_hold(chan); + chan = l2cap_chan_hold_unless_zero(l2cap_pi(sk)->chan); + if (!chan) + goto shutdown_already; BT_DBG("chan %p state %s", chan, state_to_string(chan->state)); @@ -1358,22 +1359,20 @@ static int l2cap_sock_shutdown(struct socket *sock, int how) release_sock(sk); l2cap_chan_lock(chan); - conn = chan->conn; - if (conn) - /* prevent conn structure from being freed */ - l2cap_conn_get(conn); + /* prevent conn structure from being freed */ + conn = l2cap_conn_hold_unless_zero(chan->conn); l2cap_chan_unlock(chan); if (conn) /* mutex lock must be taken before l2cap_chan_lock() */ - mutex_lock(&conn->chan_lock); + mutex_lock(&conn->lock); l2cap_chan_lock(chan); l2cap_chan_close(chan, 0); l2cap_chan_unlock(chan); if (conn) { - mutex_unlock(&conn->chan_lock); + mutex_unlock(&conn->lock); l2cap_conn_put(conn); } |
