Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit af71b816 authored by Marek Lindner's avatar Marek Lindner Committed by Greg Kroah-Hartman
Browse files

Staging: batman-adv: fix module initialization



Make sure that batman-adv does not process packets before its
initialization is complete. Some sanity checks added to the receiver
function.

Signed-off-by: default avatarMarek Lindner <lindner_marek@yahoo.de>
Signed-off-by: default avatarSimon Wunderlich <siwu@hrz.tu-chemnitz.de>
Signed-off-by: default avatarAndrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent da6d6c7a
Loading
Loading
Loading
Loading
+7 −0
Original line number Original line Diff line number Diff line
@@ -432,6 +432,9 @@ int batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
	if (!skb)
	if (!skb)
		goto err_out;
		goto err_out;


	if (atomic_read(&module_state) != MODULE_ACTIVE)
		goto err_free;

	/* packet should hold at least type and version */
	/* packet should hold at least type and version */
	if (unlikely(skb_headlen(skb) < 2))
	if (unlikely(skb_headlen(skb) < 2))
		goto err_free;
		goto err_free;
@@ -445,6 +448,10 @@ int batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
	if (!batman_if)
	if (!batman_if)
		goto err_free;
		goto err_free;


	/* discard frames on not active interfaces */
	if (batman_if->if_active != IF_ACTIVE)
		goto err_free;

	stats = (struct net_device_stats *)dev_get_stats(skb->dev);
	stats = (struct net_device_stats *)dev_get_stats(skb->dev);
	if (stats) {
	if (stats) {
		stats->rx_packets++;
		stats->rx_packets++;
+6 −11
Original line number Original line Diff line number Diff line
@@ -63,7 +63,7 @@ static ssize_t proc_interfaces_write(struct file *instance,
				     size_t count, loff_t *data)
				     size_t count, loff_t *data)
{
{
	char *if_string, *colon_ptr = NULL, *cr_ptr = NULL;
	char *if_string, *colon_ptr = NULL, *cr_ptr = NULL;
	int not_copied = 0, if_num = 0;
	int not_copied = 0, if_num = 0, add_success;
	struct batman_if *batman_if = NULL;
	struct batman_if *batman_if = NULL;


	if_string = kmalloc(count, GFP_KERNEL);
	if_string = kmalloc(count, GFP_KERNEL);
@@ -109,22 +109,17 @@ static ssize_t proc_interfaces_write(struct file *instance,
	}
	}
	rcu_read_unlock();
	rcu_read_unlock();


	hardif_add_interface(if_string, if_num);
	add_success = hardif_add_interface(if_string, if_num);
	if (add_success < 0)
		goto end;

	num_ifs = if_num + 1;


	if ((atomic_read(&module_state) == MODULE_INACTIVE) &&
	if ((atomic_read(&module_state) == MODULE_INACTIVE) &&
	    (hardif_get_active_if_num() > 0))
	    (hardif_get_active_if_num() > 0))
		activate_module();
		activate_module();


	rcu_read_lock();
	if (list_empty(&if_list)) {
		rcu_read_unlock();
		goto end;
	}
	rcu_read_unlock();

	num_ifs = if_num + 1;
	return count;
	return count;

end:
end:
	kfree(if_string);
	kfree(if_string);
	return count;
	return count;