aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Wunderlich <simon.wunderlich@s2003.tu-chemnitz.de>2012-07-01 16:51:55 -0400
committerAntonio Quartulli <ordex@autistici.org>2012-08-23 08:02:46 -0400
commit624463079e0af455a2d70d2a59b9e2f6b5827aea (patch)
tree2ca06ceb55ad048e233fba6473f4c0244b034f62
parenta51fb9b2ac4eac86ff13c30620758b87f4f3f5ce (diff)
batman-adv: check batadv_orig_hash_add_if() return code
If this call fails, some of the orig_nodes spaces may have been resized for the increased number of interface, and some may not. If we would just continue with the larger number of interfaces, this would lead to access to not allocated memory later. We better check the return code, and don't add the interface if no memory is available. OTOH, keeping some of the orig_nodes with too much memory allocated should hurt no one (except for a few too many bytes allocated). Signed-off-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de> Signed-off-by: Antonio Quartulli <ordex@autistici.org>
-rw-r--r--net/batman-adv/hard-interface.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
index 282bf6e9353e..2c5a247a8f12 100644
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -313,7 +313,13 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
313 hard_iface->if_num = bat_priv->num_ifaces; 313 hard_iface->if_num = bat_priv->num_ifaces;
314 bat_priv->num_ifaces++; 314 bat_priv->num_ifaces++;
315 hard_iface->if_status = BATADV_IF_INACTIVE; 315 hard_iface->if_status = BATADV_IF_INACTIVE;
316 batadv_orig_hash_add_if(hard_iface, bat_priv->num_ifaces); 316 ret = batadv_orig_hash_add_if(hard_iface, bat_priv->num_ifaces);
317 if (ret < 0) {
318 bat_priv->bat_algo_ops->bat_iface_disable(hard_iface);
319 bat_priv->num_ifaces--;
320 hard_iface->if_status = BATADV_IF_NOT_IN_USE;
321 goto err_dev;
322 }
317 323
318 hard_iface->batman_adv_ptype.type = ethertype; 324 hard_iface->batman_adv_ptype.type = ethertype;
319 hard_iface->batman_adv_ptype.func = batadv_batman_skb_recv; 325 hard_iface->batman_adv_ptype.func = batadv_batman_skb_recv;