From: Sven Eckelmann <sven.eckelmann@gmx.de>
To: greg@kroah.com
Cc: Vasiliy Kulikov <segooon@gmail.com>,
b.a.t.m.a.n@lists.open-mesh.net,
Marek Lindner <lindner_marek@yahoo.de>
Subject: [B.A.T.M.A.N.] [PATCH 5/5] Staging: batman-adv: check kmalloc() return value
Date: Sun, 12 Sep 2010 23:21:56 +0200 [thread overview]
Message-ID: <1284326516-30540-6-git-send-email-sven.eckelmann@gmx.de> (raw)
In-Reply-To: <1284326516-30540-1-git-send-email-sven.eckelmann@gmx.de>
From: Vasiliy Kulikov <segooon@gmail.com>
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>
---
drivers/staging/batman-adv/routing.c | 8 ++++++--
drivers/staging/batman-adv/unicast.c | 8 ++++++--
drivers/staging/batman-adv/unicast.h | 2 +-
3 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/drivers/staging/batman-adv/routing.c b/drivers/staging/batman-adv/routing.c
index e12fd99..2cf8cf9 100644
--- a/drivers/staging/batman-adv/routing.c
+++ b/drivers/staging/batman-adv/routing.c
@@ -1232,8 +1232,12 @@ 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) &&
+ create_frag_buffer(&orig_node->frag_list)) {
+ spin_unlock_irqrestore(&bat_priv->orig_hash_lock,
+ flags);
+ return NET_RX_DROP;
+ }
tmp_frag_entry =
search_frag_packet(&orig_node->frag_list,
diff --git a/drivers/staging/batman-adv/unicast.c b/drivers/staging/batman-adv/unicast.c
index f951abc..0dac50d 100644
--- a/drivers/staging/batman-adv/unicast.c
+++ b/drivers/staging/batman-adv/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/drivers/staging/batman-adv/unicast.h b/drivers/staging/batman-adv/unicast.h
index 1d5cbeb..7973697 100644
--- a/drivers/staging/batman-adv/unicast.h
+++ b/drivers/staging/batman-adv/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);
--
1.7.2.3
prev parent reply other threads:[~2010-09-12 21:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-12 21:21 [B.A.T.M.A.N.] Staging: batman-adv for 2.6.37 (2) Sven Eckelmann
2010-09-12 21:21 ` [B.A.T.M.A.N.] [PATCH 1/5] Staging: batman-adv: Always synchronize rcu's on module shutdown Sven Eckelmann
2010-09-12 21:21 ` [B.A.T.M.A.N.] [PATCH 2/5] Staging: batman-adv: Remove currently unused gw_* datastructures Sven Eckelmann
2010-09-12 21:21 ` [B.A.T.M.A.N.] [PATCH 3/5] Staging: batman-adv: Add rcu TODO Sven Eckelmann
2010-09-12 21:21 ` [B.A.T.M.A.N.] [PATCH 4/5] Staging: batman-adv: removing redundant assignment of skb->dev Sven Eckelmann
2010-09-12 21:21 ` Sven Eckelmann [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1284326516-30540-6-git-send-email-sven.eckelmann@gmx.de \
--to=sven.eckelmann@gmx.de \
--cc=b.a.t.m.a.n@lists.open-mesh.net \
--cc=b.a.t.m.a.n@lists.open-mesh.org \
--cc=greg@kroah.com \
--cc=lindner_marek@yahoo.de \
--cc=segooon@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).