From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754866AbcH0HBr convert rfc822-to-8bit (ORCPT ); Sat, 27 Aug 2016 03:01:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57844 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754742AbcH0HBp (ORCPT ); Sat, 27 Aug 2016 03:01:45 -0400 Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: <20160826152546.604384-4-arnd@arndb.de> References: <20160826152546.604384-4-arnd@arndb.de> <20160826152546.604384-1-arnd@arndb.de> To: Arnd Bergmann Cc: dhowells@redhat.com, linux-kernel@vger.kernel.org, Linus Torvalds , "David S. Miller" , netdev@vger.kernel.org Subject: Re: [PATCH 3/5] rxrpc: fix last_call processing MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <4144.1472281302.1@warthog.procyon.org.uk> Content-Transfer-Encoding: 8BIT Date: Sat, 27 Aug 2016 08:01:42 +0100 Message-ID: <4145.1472281302@warthog.procyon.org.uk> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Sat, 27 Aug 2016 07:01:44 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Arnd Bergmann wrote: > A change to the retransmission handling in rxrpc caused a use-before-init > bug in rxrpc_data_ready(), as indicated by "gcc -Wmaybe-uninitialized": > > net/rxrpc/input.c: In function 'rxrpc_data_ready': > net/rxrpc/input.c:735:34: error: 'call' may be used uninitialized in this function [-Werror=maybe-uninitialized] > > This moves the initialization of the local variable before the first > user, which presumably is what was intended here. > > Signed-off-by: Arnd Bergmann > Fixes: 18bfeba50dfd ("rxrpc: Perform terminal call ACK/ABORT retransmission from conn processor") > --- > Cc: David Howells > Cc: "David S. Miller" > Cc: netdev@vger.kernel.org > > net/rxrpc/input.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/net/rxrpc/input.c b/net/rxrpc/input.c > index 66cdeb56f44f..3c22e43a58fd 100644 > --- a/net/rxrpc/input.c > +++ b/net/rxrpc/input.c > @@ -728,6 +728,10 @@ void rxrpc_data_ready(struct sock *sk) > if (sp->hdr.callNumber < chan->last_call) > goto discard_unlock; > > + call = rcu_dereference(chan->call); > + if (!call || atomic_read(&call->usage) == 0) > + goto cant_route_call; > + > if (sp->hdr.callNumber == chan->last_call) { > /* For the previous service call, if completed > * successfully, we discard all further packets. > @@ -744,10 +748,6 @@ void rxrpc_data_ready(struct sock *sk) > goto out_unlock; > } > > - call = rcu_dereference(chan->call); > - if (!call || atomic_read(&call->usage) == 0) > - goto cant_route_call; > - > rxrpc_post_packet_to_call(call, skb); > goto out_unlock; > } You can't rearrange these like this. I have a different fix. David