All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kernel-janitors@vger.kernel.org
Subject: re: fib_trie: Add tnode struct as a container for fields not needed in key_vector
Date: Tue, 10 Mar 2015 21:04:25 +0000	[thread overview]
Message-ID: <20150310210425.GA10841@mwanda> (raw)

Hello Alexander Duyck,

The patch dc35dbeda3e0: "fib_trie: Add tnode struct as a container
for fields not needed in key_vector" from Mar 6, 2015, leads to the
following static checker warnings:

net/ipv4/fib_trie.c:330 leaf_new() warn: variable dereferenced before check 'kv' (see line 328)
net/ipv4/fib_trie.c:358 tnode_new() warn: variable dereferenced before check 'tnode' (see line 350)
net/ipv4/fib_trie.c:853 resize() error: we previously assumed 'tp' could be null (see line 835)
net/ipv4/fib_trie.c:1891 fib_trie_get_first() warn: variable dereferenced before check 't' (see line 1889)

net/ipv4/fib_trie.c
   325  static struct key_vector *leaf_new(t_key key, struct fib_alias *fa)
   326  {
   327          struct tnode *kv = kmem_cache_alloc(trie_leaf_kmem, GFP_KERNEL);
   328          struct key_vector *l = kv->kv;
                                       ^^^^^^
Deref.

   329  
   330          if (!kv)
                    ^^^
Check.

   331                  return NULL;
   332  
   333          /* initialize key vector */
   334          l->key = key;
   335          l->pos = 0;
   336          l->bits = 0;
   337          l->slen = fa->fa_slen;
   338  
   339          /* link leaf to fib alias */
   340          INIT_HLIST_HEAD(&l->leaf);
   341          hlist_add_head(&fa->fa_list, &l->leaf);
   342  
   343          return l;
   344  }

[ snip ]

   833          while (should_inflate(tp, tn) && max_work) {
   834                  tp = inflate(t, tn);
   835                  if (!tp) {
                            ^^^
Is NULL here.

   836  #ifdef CONFIG_IP_FIB_TRIE_STATS
   837                          this_cpu_inc(stats->resize_node_skipped);
   838  #endif
   839                          break;
   840                  }
   841  
   842                  max_work--;
   843                  tn = get_child(tp, cindex);
   844          }
   845  
   846          /* Return if at least one inflate is run */
   847          if (max_work != MAX_WORK)
   848                  return node_parent(tn);
   849  
   850          /* Halve as long as the number of empty children in this
   851           * node is above threshold.
   852           */
   853          while (should_halve(tp, tn) && max_work) {
                        ^^^^^^^^^^^
should_halve() used to check for NULL but now it dereferences
unconditionally.

   854                  tp = halve(t, tn);
   855                  if (!tp) {
   856  #ifdef CONFIG_IP_FIB_TRIE_STATS
   857                          this_cpu_inc(stats->resize_node_skipped);
   858  #endif
   859                          break;
   860                  }
   861  
   862                  max_work--;
   863                  tn = get_child(tp, cindex);
   864          }

regards,
dan carpenters 

             reply	other threads:[~2015-03-10 21:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-10 21:04 Dan Carpenter [this message]
2015-03-10 21:19 ` fib_trie: Add tnode struct as a container for fields not needed in key_vector Alexander Duyck
2015-03-10 21:24 ` Dan Carpenter
2015-03-10 21:36 ` Alexander Duyck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150310210425.GA10841@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=kernel-janitors@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.