diff options
author | Ralf Baechle <ralf@linux-mips.org> | 2006-06-26 03:05:23 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2006-06-26 03:05:23 -0400 |
commit | 52383678a8ac80e6679f94f60c897f9292e0e8b9 (patch) | |
tree | 071aa3fe0dd9124a645ef4c9cc7b769a5b034d91 /net/netrom | |
parent | 068c6e98bc7ec4419299b38cd40be26ebf4bdeda (diff) |
[NETROM]: Fix possible null pointer dereference.
If in nr_link_failed the neighbour list is non-empty but the node list
is empty we'll end dereferencing a in a NULL pointer.
This fixes coverity 362.
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/netrom')
-rw-r--r-- | net/netrom/nr_route.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/net/netrom/nr_route.c b/net/netrom/nr_route.c index b3b9097c87c7..c11737f472d6 100644 --- a/net/netrom/nr_route.c +++ b/net/netrom/nr_route.c | |||
@@ -725,15 +725,17 @@ void nr_link_failed(ax25_cb *ax25, int reason) | |||
725 | struct nr_node *nr_node = NULL; | 725 | struct nr_node *nr_node = NULL; |
726 | 726 | ||
727 | spin_lock_bh(&nr_neigh_list_lock); | 727 | spin_lock_bh(&nr_neigh_list_lock); |
728 | nr_neigh_for_each(s, node, &nr_neigh_list) | 728 | nr_neigh_for_each(s, node, &nr_neigh_list) { |
729 | if (s->ax25 == ax25) { | 729 | if (s->ax25 == ax25) { |
730 | nr_neigh_hold(s); | 730 | nr_neigh_hold(s); |
731 | nr_neigh = s; | 731 | nr_neigh = s; |
732 | break; | 732 | break; |
733 | } | 733 | } |
734 | } | ||
734 | spin_unlock_bh(&nr_neigh_list_lock); | 735 | spin_unlock_bh(&nr_neigh_list_lock); |
735 | 736 | ||
736 | if (nr_neigh == NULL) return; | 737 | if (nr_neigh == NULL) |
738 | return; | ||
737 | 739 | ||
738 | nr_neigh->ax25 = NULL; | 740 | nr_neigh->ax25 = NULL; |
739 | ax25_cb_put(ax25); | 741 | ax25_cb_put(ax25); |
@@ -743,11 +745,13 @@ void nr_link_failed(ax25_cb *ax25, int reason) | |||
743 | return; | 745 | return; |
744 | } | 746 | } |
745 | spin_lock_bh(&nr_node_list_lock); | 747 | spin_lock_bh(&nr_node_list_lock); |
746 | nr_node_for_each(nr_node, node, &nr_node_list) | 748 | nr_node_for_each(nr_node, node, &nr_node_list) { |
747 | nr_node_lock(nr_node); | 749 | nr_node_lock(nr_node); |
748 | if (nr_node->which < nr_node->count && nr_node->routes[nr_node->which].neighbour == nr_neigh) | 750 | if (nr_node->which < nr_node->count && |
751 | nr_node->routes[nr_node->which].neighbour == nr_neigh) | ||
749 | nr_node->which++; | 752 | nr_node->which++; |
750 | nr_node_unlock(nr_node); | 753 | nr_node_unlock(nr_node); |
754 | } | ||
751 | spin_unlock_bh(&nr_node_list_lock); | 755 | spin_unlock_bh(&nr_node_list_lock); |
752 | nr_neigh_put(nr_neigh); | 756 | nr_neigh_put(nr_neigh); |
753 | } | 757 | } |