* [B.A.T.M.A.N.] [PATCH] batman-adv: check batadv_orig_hash_add_if() return code
@ 2012-07-01 20:51 Simon Wunderlich
2012-07-05 21:47 ` Marek Lindner
0 siblings, 1 reply; 2+ messages in thread
From: Simon Wunderlich @ 2012-07-01 20:51 UTC (permalink / raw)
To: b.a.t.m.a.n; +Cc: Simon Wunderlich
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>
---
hard-interface.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/hard-interface.c b/hard-interface.c
index 282bf6e..2d7f4f2 100644
--- a/hard-interface.c
+++ b/hard-interface.c
@@ -313,7 +313,12 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
hard_iface->if_num = bat_priv->num_ifaces;
bat_priv->num_ifaces++;
hard_iface->if_status = BATADV_IF_INACTIVE;
- batadv_orig_hash_add_if(hard_iface, bat_priv->num_ifaces);
+ ret = batadv_orig_hash_add_if(hard_iface, bat_priv->num_ifaces);
+ if (ret < 0) {
+ bat_priv->bat_algo_ops->bat_iface_disable(hard_iface);
+ bat_priv->num_ifaces--;
+ goto err_dev;
+ }
hard_iface->batman_adv_ptype.type = ethertype;
hard_iface->batman_adv_ptype.func = batadv_batman_skb_recv;
--
1.7.10
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [B.A.T.M.A.N.] [PATCH] batman-adv: check batadv_orig_hash_add_if() return code
2012-07-01 20:51 [B.A.T.M.A.N.] [PATCH] batman-adv: check batadv_orig_hash_add_if() return code Simon Wunderlich
@ 2012-07-05 21:47 ` Marek Lindner
0 siblings, 0 replies; 2+ messages in thread
From: Marek Lindner @ 2012-07-05 21:47 UTC (permalink / raw)
To: The list for a Better Approach To Mobile Ad-hoc Networking
On Sunday, July 01, 2012 22:51:55 Simon Wunderlich wrote:
> 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>
> ---
> hard-interface.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
Applied in revision c4499bb.
Thanks,
Marek
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-07-05 21:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-01 20:51 [B.A.T.M.A.N.] [PATCH] batman-adv: check batadv_orig_hash_add_if() return code Simon Wunderlich
2012-07-05 21:47 ` Marek Lindner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox