[PATCH 2/2] rxrpc: fix undefined behavior in rxrpc_mark_call_released

From: Arnd Bergmann
Date: Wed Aug 31 2016 - 08:39:49 EST


gcc -Wmaybe-initialized correctly points out a newly introduced bug
through which we can end up calling rxrpc_queue_call() for a dead
connection:

net/rxrpc/call_object.c: In function 'rxrpc_mark_call_released':
net/rxrpc/call_object.c:600:5: error: 'sched' may be used uninitialized in this function [-Werror=maybe-uninitialized]

This sets the 'sched' variable to zero to restore the previous
behavior.

Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
Fixes: f5c17aaeb2ae ("rxrpc: Calls should only have one terminal state")
---
net/rxrpc/call_object.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/net/rxrpc/call_object.c b/net/rxrpc/call_object.c
index 104ee8b1de06..2daec1eaec6f 100644
--- a/net/rxrpc/call_object.c
+++ b/net/rxrpc/call_object.c
@@ -595,6 +595,8 @@ static void rxrpc_mark_call_released(struct rxrpc_call *call)
sched = __rxrpc_abort_call(call, RX_CALL_DEAD, ECONNRESET);
if (!test_and_set_bit(RXRPC_CALL_EV_RELEASE, &call->events))
sched = true;
+ } else {
+ sched = 0;
}
write_unlock(&call->state_lock);
if (sched)
--
2.9.0