[bug report] rxrpc: Rewrite the client connection manager

Dan Carpenter dan.carpenter at oracle.com
Fri Sep 11 07:32:56 EDT 2020


Hello David Howells,

The patch 245500d853e9: "rxrpc: Rewrite the client connection
manager" from Jul 1, 2020, leads to the following static checker
warning:

	net/rxrpc/conn_client.c:662 rxrpc_wait_for_channel()
	warn: 'bundle->alloc_error' is unsigned

net/rxrpc/conn_client.c
   414          candidate = rxrpc_alloc_client_connection(bundle, gfp);
   415  
   416          spin_lock(&bundle->channel_lock);
   417          bundle->alloc_conn = false;
   418  
   419          if (IS_ERR(candidate)) {
   420                  bundle->alloc_error = PTR_ERR(candidate);
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The bundle->alloc_error variable is unsigned short so it can't hold
negative values.

   421                  spin_unlock(&bundle->channel_lock);
   422                  _leave(" [err %ld]", PTR_ERR(candidate));
   423                  return;
   424          }
   425  
   426          bundle->alloc_error = 0;
   427  
   428          for (i = 0; i < ARRAY_SIZE(bundle->conns); i++) {
   429                  unsigned int shift = i * RXRPC_MAXCALLS;

[ snip ]

   642  static int rxrpc_wait_for_channel(struct rxrpc_bundle *bundle,
   643                                    struct rxrpc_call *call, gfp_t gfp)
   644  {
   645          DECLARE_WAITQUEUE(myself, current);
   646          int ret = 0;
   647  
   648          _enter("%d", call->debug_id);
   649  
   650          if (!gfpflags_allow_blocking(gfp)) {
   651                  rxrpc_maybe_add_conn(bundle, gfp);
   652                  rxrpc_activate_channels(bundle);
   653                  ret = bundle->alloc_error ?: -EAGAIN;
   654                  goto out;
   655          }
   656  
   657          add_wait_queue_exclusive(&call->waitq, &myself);
   658          for (;;) {
   659                  rxrpc_maybe_add_conn(bundle, gfp);
   660                  rxrpc_activate_channels(bundle);
   661                  ret = bundle->alloc_error;
                        ^^^^^^^^^^^^^^^^^^^^^^^^^

   662                  if (ret < 0)
                            ^^^^^^^
Impossible condition.

   663                          break;
   664  
   665                  switch (call->interruptibility) {
   666                  case RXRPC_INTERRUPTIBLE:
   667                  case RXRPC_PREINTERRUPTIBLE:
   668                          set_current_state(TASK_INTERRUPTIBLE);
   669                          break;
   670                  case RXRPC_UNINTERRUPTIBLE:

regards,
dan carpenter



More information about the linux-afs mailing list