diff options
author | Marek Lindner <lindner_marek@yahoo.de> | 2011-04-20 09:40:58 -0400 |
---|---|---|
committer | Sven Eckelmann <sven@narfation.org> | 2011-05-01 16:49:03 -0400 |
commit | 32ae9b221e788413ce68feaae2ca39e406211a0a (patch) | |
tree | d827f989976a28fea5cdcb349c308baa98182c35 /net/batman-adv/gateway_client.c | |
parent | 71e4aa9c465fd66c110667ab5d620fb6a4ef2157 (diff) |
batman-adv: Make bat_priv->primary_if an rcu protected pointer
The rcu protected macros rcu_dereference() and rcu_assign_pointer()
for the bat_priv->primary_if need to be used, as well as spin/rcu locking.
Otherwise we might end up using a primary_if pointer pointing to already
freed memory.
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Diffstat (limited to 'net/batman-adv/gateway_client.c')
-rw-r--r-- | net/batman-adv/gateway_client.c | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c index af128eff2edf..65f39530799d 100644 --- a/net/batman-adv/gateway_client.c +++ b/net/batman-adv/gateway_client.c | |||
@@ -439,30 +439,32 @@ int gw_client_seq_print_text(struct seq_file *seq, void *offset) | |||
439 | { | 439 | { |
440 | struct net_device *net_dev = (struct net_device *)seq->private; | 440 | struct net_device *net_dev = (struct net_device *)seq->private; |
441 | struct bat_priv *bat_priv = netdev_priv(net_dev); | 441 | struct bat_priv *bat_priv = netdev_priv(net_dev); |
442 | struct hard_iface *primary_if; | ||
442 | struct gw_node *gw_node; | 443 | struct gw_node *gw_node; |
443 | struct hlist_node *node; | 444 | struct hlist_node *node; |
444 | int gw_count = 0; | 445 | int gw_count = 0, ret = 0; |
445 | 446 | ||
446 | if (!bat_priv->primary_if) { | 447 | primary_if = primary_if_get_selected(bat_priv); |
447 | 448 | if (!primary_if) { | |
448 | return seq_printf(seq, "BATMAN mesh %s disabled - please " | 449 | ret = seq_printf(seq, "BATMAN mesh %s disabled - please " |
449 | "specify interfaces to enable it\n", | 450 | "specify interfaces to enable it\n", |
450 | net_dev->name); | 451 | net_dev->name); |
452 | goto out; | ||
451 | } | 453 | } |
452 | 454 | ||
453 | if (bat_priv->primary_if->if_status != IF_ACTIVE) { | 455 | if (primary_if->if_status != IF_ACTIVE) { |
454 | 456 | ret = seq_printf(seq, "BATMAN mesh %s disabled - " | |
455 | return seq_printf(seq, "BATMAN mesh %s disabled - " | 457 | "primary interface not active\n", |
456 | "primary interface not active\n", | 458 | net_dev->name); |
457 | net_dev->name); | 459 | goto out; |
458 | } | 460 | } |
459 | 461 | ||
460 | seq_printf(seq, " %-12s (%s/%i) %17s [%10s]: gw_class ... " | 462 | seq_printf(seq, " %-12s (%s/%i) %17s [%10s]: gw_class ... " |
461 | "[B.A.T.M.A.N. adv %s%s, MainIF/MAC: %s/%pM (%s)]\n", | 463 | "[B.A.T.M.A.N. adv %s%s, MainIF/MAC: %s/%pM (%s)]\n", |
462 | "Gateway", "#", TQ_MAX_VALUE, "Nexthop", | 464 | "Gateway", "#", TQ_MAX_VALUE, "Nexthop", |
463 | "outgoingIF", SOURCE_VERSION, REVISION_VERSION_STR, | 465 | "outgoingIF", SOURCE_VERSION, REVISION_VERSION_STR, |
464 | bat_priv->primary_if->net_dev->name, | 466 | primary_if->net_dev->name, |
465 | bat_priv->primary_if->net_dev->dev_addr, net_dev->name); | 467 | primary_if->net_dev->dev_addr, net_dev->name); |
466 | 468 | ||
467 | rcu_read_lock(); | 469 | rcu_read_lock(); |
468 | hlist_for_each_entry_rcu(gw_node, node, &bat_priv->gw_list, list) { | 470 | hlist_for_each_entry_rcu(gw_node, node, &bat_priv->gw_list, list) { |
@@ -480,7 +482,10 @@ int gw_client_seq_print_text(struct seq_file *seq, void *offset) | |||
480 | if (gw_count == 0) | 482 | if (gw_count == 0) |
481 | seq_printf(seq, "No gateways in range ...\n"); | 483 | seq_printf(seq, "No gateways in range ...\n"); |
482 | 484 | ||
483 | return 0; | 485 | out: |
486 | if (primary_if) | ||
487 | hardif_free_ref(primary_if); | ||
488 | return ret; | ||
484 | } | 489 | } |
485 | 490 | ||
486 | int gw_is_target(struct bat_priv *bat_priv, struct sk_buff *skb) | 491 | int gw_is_target(struct bat_priv *bat_priv, struct sk_buff *skb) |