* [B.A.T.M.A.N.] [PATCHv2] batman-adv: avoid double free when orig_node initialization fails
@ 2014-02-15 1:17 Antonio Quartulli
2014-02-15 1:27 ` Marek Lindner
0 siblings, 1 reply; 2+ messages in thread
From: Antonio Quartulli @ 2014-02-15 1:17 UTC (permalink / raw)
To: b.a.t.m.a.n; +Cc: Antonio Quartulli
In the failure path of the orig_node initialization routine
the orig_node->bat_iv.bcast_own field is free'd twice: first
in batadv_iv_ogm_orig_get() and then later in
batadv_orig_node_free_rcu().
Fix it by removing the kfree in batadv_iv_ogm_orig_get().
Signed-off-by: Antonio Quartulli <antonio@meshcoding.com>
---
Change form v1:
- remove kfree from batadv_iv_ogm_orig_get() instead of setting
orig_node->bat_iv.bcast_own to NULL
bat_iv_ogm.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/bat_iv_ogm.c b/bat_iv_ogm.c
index c07e59f..fdf4322 100644
--- a/bat_iv_ogm.c
+++ b/bat_iv_ogm.c
@@ -243,18 +243,16 @@ batadv_iv_ogm_orig_get(struct batadv_priv *bat_priv, const uint8_t *addr)
size = bat_priv->num_ifaces * sizeof(uint8_t);
orig_node->bat_iv.bcast_own_sum = kzalloc(size, GFP_ATOMIC);
if (!orig_node->bat_iv.bcast_own_sum)
- goto free_bcast_own;
+ goto free_orig_node;
hash_added = batadv_hash_add(bat_priv->orig_hash, batadv_compare_orig,
batadv_choose_orig, orig_node,
&orig_node->hash_entry);
if (hash_added != 0)
- goto free_bcast_own;
+ goto free_orig_node;
return orig_node;
-free_bcast_own:
- kfree(orig_node->bat_iv.bcast_own);
free_orig_node:
/* free twice, as batadv_orig_node_new sets refcount to 2 */
batadv_orig_node_free_ref(orig_node);
--
1.8.5.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [B.A.T.M.A.N.] [PATCHv2] batman-adv: avoid double free when orig_node initialization fails
2014-02-15 1:17 [B.A.T.M.A.N.] [PATCHv2] batman-adv: avoid double free when orig_node initialization fails Antonio Quartulli
@ 2014-02-15 1:27 ` Marek Lindner
0 siblings, 0 replies; 2+ messages in thread
From: Marek Lindner @ 2014-02-15 1:27 UTC (permalink / raw)
To: b.a.t.m.a.n; +Cc: Antonio Quartulli
[-- Attachment #1: Type: text/plain, Size: 655 bytes --]
On Saturday 15 February 2014 02:17:20 Antonio Quartulli wrote:
> In the failure path of the orig_node initialization routine
> the orig_node->bat_iv.bcast_own field is free'd twice: first
> in batadv_iv_ogm_orig_get() and then later in
> batadv_orig_node_free_rcu().
>
> Fix it by removing the kfree in batadv_iv_ogm_orig_get().
>
> Signed-off-by: Antonio Quartulli <antonio@meshcoding.com>
> ---
>
> Change form v1:
> - remove kfree from batadv_iv_ogm_orig_get() instead of setting
> orig_node->bat_iv.bcast_own to NULL
>
>
> bat_iv_ogm.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
Applied in revision d4acda1.
Thanks,
Marek
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 490 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-02-15 1:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-15 1:17 [B.A.T.M.A.N.] [PATCHv2] batman-adv: avoid double free when orig_node initialization fails Antonio Quartulli
2014-02-15 1:27 ` Marek Lindner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).