packages/net/batman-advanced/patches/0005-batman-adv-Don-t-write-in-not-allocated-packet_buff.patch
marek 2de2e5f023 batman-adv: adding stability patches
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>



git-svn-id: svn://svn.openwrt.org/openwrt/packages@22823 3c298f89-4303-0410-b956-a3cf2f4a3e73
2010-08-27 17:42:48 +00:00

53 lines
1.9 KiB
Diff

From e3a0cc90940915dd14e4ca6bdab6d74bbc60f4a4 Mon Sep 17 00:00:00 2001
From: Sven Eckelmann <sven.eckelmann@gmx.de>
Date: Fri, 20 Aug 2010 17:32:38 +0200
Subject: [PATCH 10/10] batman-adv: Don't write in not allocated packet_buff
Each net_device in a system will automatically managed as a possible
batman_if and holds different informations like a buffer with a prepared
originator messages. To reduce the memory usage, the packet_buff will
only be allocated when the interface is really added/enabled for
batman-adv.
The function to update the hw address information inside the packet_buff
just assumes that the packet_buff is always initialised and thus the
kernel will just oops when we try to change the hw address of a not
already fully enabled interface.
We must always check if the packet_buff is allocated before we try to
change information inside of it.
Reported-by: Tim Glaremin <Tim.Glaremin@web.de>
Reported-by: Kazuki Shimada <zukky@bb.banban.jp>
Signed-off-by: Sven Eckelmann <sven.eckelmann@gmx.de>
Cc: stable <stable@kernel.org>
---
hard-interface.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/hard-interface.c b/hard-interface.c
index ce6819a..4ef6504 100644
--- a/hard-interface.c
+++ b/hard-interface.c
@@ -131,6 +131,9 @@ static bool hardif_is_iface_up(struct batman_if *batman_if)
static void update_mac_addresses(struct batman_if *batman_if)
{
+ if (!batman_if || !batman_if->packet_buff)
+ return;
+
addr_to_string(batman_if->addr_str, batman_if->net_dev->dev_addr);
memcpy(((struct batman_packet *)(batman_if->packet_buff))->orig,
@@ -336,6 +339,7 @@ static struct batman_if *hardif_add_interface(struct net_device *net_dev)
batman_if->if_num = -1;
batman_if->net_dev = net_dev;
batman_if->if_status = IF_NOT_IN_USE;
+ batman_if->packet_buff = NULL;
INIT_LIST_HEAD(&batman_if->list);
check_known_mac_addr(batman_if->net_dev->dev_addr);
--
1.7.1