diff options
author | Sven Eckelmann <sven.eckelmann@gmx.de> | 2010-08-21 14:18:10 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-08-26 16:46:23 -0700 |
commit | 964505fabe0410e11cc5487a9a4b17dbec461ffd (patch) | |
tree | c64f3990907d20a59b8495b71934ba096ca2ac15 | |
parent | b6c68ad83cbc3bcf4ff83f62340fbf891f44735c (diff) | |
download | kernel-crypto-964505fabe0410e11cc5487a9a4b17dbec461ffd.tar.gz kernel-crypto-964505fabe0410e11cc5487a9a4b17dbec461ffd.tar.xz kernel-crypto-964505fabe0410e11cc5487a9a4b17dbec461ffd.zip |
Staging: batman-adv: Don't write in not allocated packet_buff
commit f86b9984250fa2b71ce36d4693a939a58579583b upstream.
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/staging/batman-adv/hard-interface.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/staging/batman-adv/hard-interface.c b/drivers/staging/batman-adv/hard-interface.c index d108fa1eb73..ce1d2512047 100644 --- a/drivers/staging/batman-adv/hard-interface.c +++ b/drivers/staging/batman-adv/hard-interface.c @@ -128,6 +128,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, @@ -338,6 +341,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); |