[commits] batman-adv; branch, next, updated. v2010.1.0-27-g69d187f

postmaster at open-mesh.net postmaster at open-mesh.net
Sun Sep 12 21:41:35 CEST 2010


The following commit has been merged in the next branch:
commit 69d187ffb8e22024a87d8457e5dcb10e297108e9
Author: Vasiliy Kulikov <segooon at gmail.com>
Date:   Sun Sep 12 19:36:56 2010 +0000

    staging: batman-adv: check kmalloc() return value
    
    kmalloc() may fail, if so drop current packet.
    
    Signed-off-by: Vasiliy Kulikov <segooon at gmail.com>
    Signed-off-by: Marek Lindner <lindner_marek at yahoo.de>

diff --git a/routing.c b/routing.c
index 128c57c..23a12cd 100644
--- a/routing.c
+++ b/routing.c
@@ -1233,8 +1233,10 @@ int recv_ucast_frag_packet(struct sk_buff *skb, struct batman_if *recv_if)
 
 		orig_node->last_frag_packet = jiffies;
 
-		if (list_empty(&orig_node->frag_list))
-			create_frag_buffer(&orig_node->frag_list);
+		if (list_empty(&orig_node->frag_list)) {
+			if (create_frag_buffer(&orig_node->frag_list))
+				return NET_RX_DROP;
+		}
 
 		tmp_frag_entry =
 			search_frag_packet(&orig_node->frag_list,
diff --git a/unicast.c b/unicast.c
index f951abc..0dac50d 100644
--- a/unicast.c
+++ b/unicast.c
@@ -78,7 +78,7 @@ void create_frag_entry(struct list_head *head, struct sk_buff *skb)
 	return;
 }
 
-void create_frag_buffer(struct list_head *head)
+int create_frag_buffer(struct list_head *head)
 {
 	int i;
 	struct frag_packet_list_entry *tfp;
@@ -86,13 +86,17 @@ void create_frag_buffer(struct list_head *head)
 	for (i = 0; i < FRAG_BUFFER_SIZE; i++) {
 		tfp = kmalloc(sizeof(struct frag_packet_list_entry),
 			GFP_ATOMIC);
+		if (!tfp) {
+			frag_list_free(head);
+			return -ENOMEM;
+		}
 		tfp->skb = NULL;
 		tfp->seqno = 0;
 		INIT_LIST_HEAD(&tfp->list);
 		list_add(&tfp->list, head);
 	}
 
-	return;
+	return 0;
 }
 
 struct frag_packet_list_entry *search_frag_packet(struct list_head *head,
diff --git a/unicast.h b/unicast.h
index 1d5cbeb..7973697 100644
--- a/unicast.h
+++ b/unicast.h
@@ -30,7 +30,7 @@ struct sk_buff *merge_frag_packet(struct list_head *head,
 	struct sk_buff *skb);
 
 void create_frag_entry(struct list_head *head, struct sk_buff *skb);
-void create_frag_buffer(struct list_head *head);
+int create_frag_buffer(struct list_head *head);
 struct frag_packet_list_entry *search_frag_packet(struct list_head *head,
 	struct unicast_frag_packet *up);
 void frag_list_free(struct list_head *head);

-- 
batman-adv


More information about the commits mailing list