aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorAlexander Duyck <alexander.h.duyck@redhat.com>2015-03-23 14:51:53 -0400
committerDavid S. Miller <davem@davemloft.net>2015-03-23 16:58:32 -0400
commitb6f15f828d4b624a2e4306dabbbb20a581bece37 (patch)
tree78a27659a48bc7be32ef10407be3dfc21c440797 /net
parent9cde94506eacfcda570b6c304b8deae1a7191ee2 (diff)
fib_trie: Fix regression in handling of inflate/halve failure
When I updated the code to address a possible null pointer dereference in resize I ended up reverting an exception handling fix for the suffix length in the event that inflate or halve failed. This change is meant to correct that by reverting the earlier fix and instead simply getting the parent again after inflate has been completed to avoid the possible null pointer issue. Fixes: ddb4b9a13 ("fib_trie: Address possible NULL pointer dereference in resize") Signed-off-by: Alexander Duyck <alexander.h.duyck@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/ipv4/fib_trie.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index e3b4aee4244e..2c7c299ee2b9 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -830,7 +830,7 @@ static struct key_vector *resize(struct trie *t, struct key_vector *tn)
830 /* Double as long as the resulting node has a number of 830 /* Double as long as the resulting node has a number of
831 * nonempty nodes that are above the threshold. 831 * nonempty nodes that are above the threshold.
832 */ 832 */
833 while (should_inflate(tp, tn) && max_work--) { 833 while (should_inflate(tp, tn) && max_work) {
834 tp = inflate(t, tn); 834 tp = inflate(t, tn);
835 if (!tp) { 835 if (!tp) {
836#ifdef CONFIG_IP_FIB_TRIE_STATS 836#ifdef CONFIG_IP_FIB_TRIE_STATS
@@ -839,17 +839,21 @@ static struct key_vector *resize(struct trie *t, struct key_vector *tn)
839 break; 839 break;
840 } 840 }
841 841
842 max_work--;
842 tn = get_child(tp, cindex); 843 tn = get_child(tp, cindex);
843 } 844 }
844 845
846 /* update parent in case inflate failed */
847 tp = node_parent(tn);
848
845 /* Return if at least one inflate is run */ 849 /* Return if at least one inflate is run */
846 if (max_work != MAX_WORK) 850 if (max_work != MAX_WORK)
847 return node_parent(tn); 851 return tp;
848 852
849 /* Halve as long as the number of empty children in this 853 /* Halve as long as the number of empty children in this
850 * node is above threshold. 854 * node is above threshold.
851 */ 855 */
852 while (should_halve(tp, tn) && max_work--) { 856 while (should_halve(tp, tn) && max_work) {
853 tp = halve(t, tn); 857 tp = halve(t, tn);
854 if (!tp) { 858 if (!tp) {
855#ifdef CONFIG_IP_FIB_TRIE_STATS 859#ifdef CONFIG_IP_FIB_TRIE_STATS
@@ -858,6 +862,7 @@ static struct key_vector *resize(struct trie *t, struct key_vector *tn)
858 break; 862 break;
859 } 863 }
860 864
865 max_work--;
861 tn = get_child(tp, cindex); 866 tn = get_child(tp, cindex);
862 } 867 }
863 868
@@ -865,7 +870,7 @@ static struct key_vector *resize(struct trie *t, struct key_vector *tn)
865 if (should_collapse(tn)) 870 if (should_collapse(tn))
866 return collapse(t, tn); 871 return collapse(t, tn);
867 872
868 /* update parent in case inflate or halve failed */ 873 /* update parent in case halve failed */
869 tp = node_parent(tn); 874 tp = node_parent(tn);
870 875
871 /* Return if at least one deflate was run */ 876 /* Return if at least one deflate was run */