mirror of
https://github.com/torvalds/linux
synced 2024-11-05 18:23:50 +00:00
Bluetooth: Unwind l2cap_sock_shutdown()
l2cap_sock_shutdown() is designed to only action shutdown of the channel when shutdown is not already in progress. Therefore, reorganise the code flow by adding a goto to jump to the end of function handling when shutdown is already being actioned. This removes one level of code indentation and make the code more readable. Signed-off-by: Dean Jenkins <Dean_Jenkins@mentor.com> Signed-off-by: Harish Jenny K N <harish_kandiga@mentor.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
This commit is contained in:
parent
09bf420f10
commit
e7456437c1
1 changed files with 18 additions and 14 deletions
|
@ -1111,6 +1111,11 @@ static int l2cap_sock_shutdown(struct socket *sock, int how)
|
|||
if (!sk)
|
||||
return 0;
|
||||
|
||||
if (sk->sk_shutdown)
|
||||
goto shutdown_already;
|
||||
|
||||
BT_DBG("Handling sock shutdown");
|
||||
|
||||
/* prevent sk structure from being freed whilst unlocked */
|
||||
sock_hold(sk);
|
||||
|
||||
|
@ -1127,7 +1132,6 @@ static int l2cap_sock_shutdown(struct socket *sock, int how)
|
|||
l2cap_chan_lock(chan);
|
||||
lock_sock(sk);
|
||||
|
||||
if (!sk->sk_shutdown) {
|
||||
if (chan->mode == L2CAP_MODE_ERTM &&
|
||||
chan->unacked_frames > 0 &&
|
||||
chan->state == BT_CONNECTED)
|
||||
|
@ -1143,7 +1147,6 @@ static int l2cap_sock_shutdown(struct socket *sock, int how)
|
|||
!(current->flags & PF_EXITING))
|
||||
err = bt_sock_wait_state(sk, BT_CLOSED,
|
||||
sk->sk_lingertime);
|
||||
}
|
||||
|
||||
if (!err && sk->sk_err)
|
||||
err = -sk->sk_err;
|
||||
|
@ -1157,6 +1160,7 @@ static int l2cap_sock_shutdown(struct socket *sock, int how)
|
|||
l2cap_chan_put(chan);
|
||||
sock_put(sk);
|
||||
|
||||
shutdown_already:
|
||||
BT_DBG("err: %d", err);
|
||||
|
||||
return err;
|
||||
|
|
Loading…
Reference in a new issue