Staging: batman-adv: check kmalloc() return value

kmalloc() may fail, if so drop current packet.

Signed-off-by: Vasiliy Kulikov <segooon@gmail.com>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
[sven.eckelmann@gmx.de: Removed new introduced deadlock]
Signed-off-by: Sven Eckelmann <sven.eckelmann@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
Vasiliy Kulikov
2010-09-12 23:21:56 +02:00
committed by Greg Kroah-Hartman
parent b001f71ed1
commit ff75f96bb0
3 changed files with 13 additions and 5 deletions

View File

@@ -1232,8 +1232,12 @@ int recv_ucast_frag_packet(struct sk_buff *skb, struct batman_if *recv_if)
orig_node->last_frag_packet = jiffies; orig_node->last_frag_packet = jiffies;
if (list_empty(&orig_node->frag_list)) if (list_empty(&orig_node->frag_list) &&
create_frag_buffer(&orig_node->frag_list); create_frag_buffer(&orig_node->frag_list)) {
spin_unlock_irqrestore(&bat_priv->orig_hash_lock,
flags);
return NET_RX_DROP;
}
tmp_frag_entry = tmp_frag_entry =
search_frag_packet(&orig_node->frag_list, search_frag_packet(&orig_node->frag_list,

View File

@@ -78,7 +78,7 @@ void create_frag_entry(struct list_head *head, struct sk_buff *skb)
return; return;
} }
void create_frag_buffer(struct list_head *head) int create_frag_buffer(struct list_head *head)
{ {
int i; int i;
struct frag_packet_list_entry *tfp; 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++) { for (i = 0; i < FRAG_BUFFER_SIZE; i++) {
tfp = kmalloc(sizeof(struct frag_packet_list_entry), tfp = kmalloc(sizeof(struct frag_packet_list_entry),
GFP_ATOMIC); GFP_ATOMIC);
if (!tfp) {
frag_list_free(head);
return -ENOMEM;
}
tfp->skb = NULL; tfp->skb = NULL;
tfp->seqno = 0; tfp->seqno = 0;
INIT_LIST_HEAD(&tfp->list); INIT_LIST_HEAD(&tfp->list);
list_add(&tfp->list, head); list_add(&tfp->list, head);
} }
return; return 0;
} }
struct frag_packet_list_entry *search_frag_packet(struct list_head *head, struct frag_packet_list_entry *search_frag_packet(struct list_head *head,

View File

@@ -30,7 +30,7 @@ struct sk_buff *merge_frag_packet(struct list_head *head,
struct sk_buff *skb); struct sk_buff *skb);
void create_frag_entry(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 frag_packet_list_entry *search_frag_packet(struct list_head *head,
struct unicast_frag_packet *up); struct unicast_frag_packet *up);
void frag_list_free(struct list_head *head); void frag_list_free(struct list_head *head);