/* Double as long as the resulting node has a number of
         * nonempty nodes that are above the threshold.
         */
-       while (should_inflate(tp, tn) && max_work) {
+       while (should_inflate(tp, tn) && max_work--) {
                tp = inflate(t, tn);
                if (!tp) {
 #ifdef CONFIG_IP_FIB_TRIE_STATS
                        break;
                }
 
-               max_work--;
                tn = get_child(tp, cindex);
        }
 
        /* Halve as long as the number of empty children in this
         * node is above threshold.
         */
-       while (should_halve(tp, tn) && max_work) {
+       while (should_halve(tp, tn) && max_work--) {
                tp = halve(t, tn);
                if (!tp) {
 #ifdef CONFIG_IP_FIB_TRIE_STATS
                        break;
                }
 
-               max_work--;
                tn = get_child(tp, cindex);
        }