aboutsummaryrefslogtreecommitdiff
path: root/drivers/staging/batman-adv/routing.c
diff options
context:
space:
mode:
authorSimon Wunderlich <siwu@hrz.tu-chemnitz.de>2010-01-02 11:30:47 +0100
committerGreg Kroah-Hartman <gregkh@suse.de>2010-03-03 16:42:35 -0800
commitc4bf05d3960981a4291bcc9580f3d73eb4dcbe84 (patch)
tree9d9f214988a259ba96f522ee65e741cec1b9bef9 /drivers/staging/batman-adv/routing.c
parente9b764506aeb06ada6a7d0a24eda3e6eb70bade1 (diff)
Staging: batman-adv: check all kmalloc()s
there are some kmallocs left which are not checked whether they succeeds or not, which might lead to corrupted data structures if the system memory is full. This patch should clean up the remaining unchecked kmalloc()s. Signed-off-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de> Signed-off-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/batman-adv/routing.c')
-rw-r--r--drivers/staging/batman-adv/routing.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/drivers/staging/batman-adv/routing.c b/drivers/staging/batman-adv/routing.c
index 37c53822e9c..f8464cad30b 100644
--- a/drivers/staging/batman-adv/routing.c
+++ b/drivers/staging/batman-adv/routing.c
@@ -154,11 +154,14 @@ static int isBidirectionalNeigh(struct orig_node *orig_node,
neigh_node = tmp_neigh_node;
}
- if (neigh_node == NULL)
+ if (!neigh_node)
neigh_node = create_neighbor(orig_node,
orig_neigh_node,
orig_neigh_node->orig,
if_incoming);
+ /* create_neighbor failed, return 0 */
+ if (!neigh_node)
+ return 0;
neigh_node->last_valid = jiffies;
} else {
@@ -172,11 +175,14 @@ static int isBidirectionalNeigh(struct orig_node *orig_node,
neigh_node = tmp_neigh_node;
}
- if (neigh_node == NULL)
+ if (!neigh_node)
neigh_node = create_neighbor(orig_neigh_node,
orig_neigh_node,
orig_neigh_node->orig,
if_incoming);
+ /* create_neighbor failed, return 0 */
+ if (!neigh_node)
+ return 0;
}
orig_node->last_valid = jiffies;
@@ -260,11 +266,19 @@ static void update_orig(struct orig_node *orig_node, struct ethhdr *ethhdr,
ring_buffer_avg(tmp_neigh_node->tq_recv);
}
- if (neigh_node == NULL)
+ if (!neigh_node) {
+ struct orig_node *orig_tmp;
+
+ orig_tmp = get_orig_node(ethhdr->h_source);
+ if (!orig_tmp)
+ return;
+
neigh_node = create_neighbor(orig_node,
- get_orig_node(ethhdr->h_source),
+ orig_tmp,
ethhdr->h_source, if_incoming);
- else
+ if (!neigh_node)
+ return;
+ } else
bat_dbg(DBG_BATMAN,
"Updating existing last-hop neighbor of originator\n");
@@ -444,6 +458,9 @@ void receive_bat_packet(struct ethhdr *ethhdr,
orig_neigh_node = get_orig_node(ethhdr->h_source);
+ if (!orig_neigh_node)
+ return;
+
/* neighbor has to indicate direct link and it has to
* come via the corresponding interface */
/* if received seqno equals last send seqno save new