diff options
author | Sven Eckelmann <sven.eckelmann@gmx.de> | 2010-08-21 08:18:10 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-08-23 21:15:38 -0400 |
commit | f86b9984250fa2b71ce36d4693a939a58579583b (patch) | |
tree | 3eb64c2a22559d122e636171dac50a33c66ae456 /drivers | |
parent | 51a00eaf6e008b60943af6ab68c17ac3622208dc (diff) |
Staging: 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>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-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 d08491ed5455..baa8b05b9e8d 100644 --- a/drivers/staging/batman-adv/hard-interface.c +++ b/drivers/staging/batman-adv/hard-interface.c | |||
@@ -129,6 +129,9 @@ static bool hardif_is_iface_up(struct batman_if *batman_if) | |||
129 | 129 | ||
130 | static void update_mac_addresses(struct batman_if *batman_if) | 130 | static void update_mac_addresses(struct batman_if *batman_if) |
131 | { | 131 | { |
132 | if (!batman_if || !batman_if->packet_buff) | ||
133 | return; | ||
134 | |||
132 | addr_to_string(batman_if->addr_str, batman_if->net_dev->dev_addr); | 135 | addr_to_string(batman_if->addr_str, batman_if->net_dev->dev_addr); |
133 | 136 | ||
134 | memcpy(((struct batman_packet *)(batman_if->packet_buff))->orig, | 137 | memcpy(((struct batman_packet *)(batman_if->packet_buff))->orig, |
@@ -334,6 +337,7 @@ static struct batman_if *hardif_add_interface(struct net_device *net_dev) | |||
334 | batman_if->if_num = -1; | 337 | batman_if->if_num = -1; |
335 | batman_if->net_dev = net_dev; | 338 | batman_if->net_dev = net_dev; |
336 | batman_if->if_status = IF_NOT_IN_USE; | 339 | batman_if->if_status = IF_NOT_IN_USE; |
340 | batman_if->packet_buff = NULL; | ||
337 | INIT_LIST_HEAD(&batman_if->list); | 341 | INIT_LIST_HEAD(&batman_if->list); |
338 | 342 | ||
339 | check_known_mac_addr(batman_if->net_dev->dev_addr); | 343 | check_known_mac_addr(batman_if->net_dev->dev_addr); |