Unlock before BUG, but preserve normal operation
PATCH 1/1 Unlock before BUG, but preserve normal operation
I am a bit uncertain about this, so if you have comments on this, it is much appreciated.
The rationale:
in the default case the BUG() kills the current process, but with the lock still held this causes the system to hang; therefore the unlock before the BUG().
When CONFIG_BUG is disabled - e.g. for embedded systems - the BUG(); will not kill the process and there should not be a double unlock in that case. --
Unlock before BUG(), but preserve normal operation in the case that CONFIG_BUG is disabled.
Signed-off-by Roel Kluin <[email protected]>
---
drivers/net/wireless/ipw2200.c +2 -0
@@ -8722,7 +8722,9 @@ static int ipw_wx_get_freq(struct net_device *dev,break ;default : +mutex_unlock (&priv->mutex);BUG (); +return -EINVAL ; } }else wrqu->freq.m =0 ;
net/rxrpc/ar-ack.c +4 -1
@@ -752,8 +752,11 @@ all_acked: sp->call = call;rxrpc_get_call (call);spin_lock_bh (&call->lock); -if (rxrpc_queue_rcv_skb (call, skb, true, true) <0 ) +if (rxrpc_queue_rcv_skb (call, skb, true, true) <0 ) { +spin_unlock_bh (&call->lock);BUG (); + goto process_further; + }spin_unlock_bh (&call->lock); goto process_further; }
net/rxrpc/ar-call.c +5 -2
@@ -426,9 +426,12 @@ void rxrpc_release_call(struct rxrpc_call *call) call->rx_first_oos);spin_lock_bh (&call->lock); -if (test_and_set_bit (RXRPC_CALL_RELEASED , &call->flags)) +if (test_and_set_bit (RXRPC_CALL_RELEASED , &call->flags)) { +spin_unlock_bh (&call->lock);BUG (); -spin_unlock_bh (&call->lock); + }else { +spin_unlock_bh (&call->lock); + }/* dissociate from the socket * - the socket's ref on the call is passed to the death timer