* [PATCH] staging: batman-adv: check kmalloc() return value
@ 2010-09-12 18:56 Vasiliy Kulikov
2010-09-12 19:57 ` Marek Lindner
2010-09-12 20:43 ` Sven Eckelmann
0 siblings, 2 replies; 3+ messages in thread
From: Vasiliy Kulikov @ 2010-09-12 18:56 UTC (permalink / raw)
To: kernel-janitors
Cc: Greg Kroah-Hartman, Andrew Lunn, Sven Eckelmann, Marek Lindner,
Simon Wunderlich, Andreas Langer, devel, linux-kernel
kmalloc() may fail, if so drop current packet.
Signed-off-by: Vasiliy Kulikov <segooon@gmail.com>
---
Compile tested.
drivers/staging/batman-adv/routing.c | 6 ++++--
drivers/staging/batman-adv/unicast.c | 8 ++++++--
drivers/staging/batman-adv/unicast.h | 2 +-
3 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/drivers/staging/batman-adv/routing.c b/drivers/staging/batman-adv/routing.c
index e12fd99..e545260 100644
--- a/drivers/staging/batman-adv/routing.c
+++ b/drivers/staging/batman-adv/routing.c
@@ -1232,8 +1232,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/drivers/staging/batman-adv/unicast.c b/drivers/staging/batman-adv/unicast.c
index f951abc..f7d2206 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 = NULL) {
+ 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.0.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] staging: batman-adv: check kmalloc() return value
2010-09-12 18:56 [PATCH] staging: batman-adv: check kmalloc() return value Vasiliy Kulikov
@ 2010-09-12 19:57 ` Marek Lindner
2010-09-12 20:43 ` Sven Eckelmann
1 sibling, 0 replies; 3+ messages in thread
From: Marek Lindner @ 2010-09-12 19:57 UTC (permalink / raw)
To: Vasiliy Kulikov
Cc: kernel-janitors, Greg Kroah-Hartman, Andrew Lunn, Sven Eckelmann,
Simon Wunderlich, Andreas Langer, devel, linux-kernel
On Sunday 12 September 2010 20:56:26 Vasiliy Kulikov wrote:
> kmalloc() may fail, if so drop current packet.
>
> Signed-off-by: Vasiliy Kulikov <segooon@gmail.com>
Looks good to me. Added this patch to our repos.
Thanks,
Marek
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] staging: batman-adv: check kmalloc() return value
2010-09-12 18:56 [PATCH] staging: batman-adv: check kmalloc() return value Vasiliy Kulikov
2010-09-12 19:57 ` Marek Lindner
@ 2010-09-12 20:43 ` Sven Eckelmann
1 sibling, 0 replies; 3+ messages in thread
From: Sven Eckelmann @ 2010-09-12 20:43 UTC (permalink / raw)
To: b.a.t.m.a.n
Cc: Vasiliy Kulikov, kernel-janitors, Greg Kroah-Hartman, Andrew Lunn,
Marek Lindner, Simon Wunderlich, Andreas Langer, devel,
linux-kernel
[-- Attachment #1: Type: Text/Plain, Size: 1261 bytes --]
Vasiliy Kulikov wrote:
> kmalloc() may fail, if so drop current packet.
Thanks for your patch. The indention is right, but it adds just another bug
(locking related).
> Signed-off-by: Vasiliy Kulikov <segooon@gmail.com>
> ---
> Compile tested.
>
> drivers/staging/batman-adv/routing.c | 6 ++++--
> drivers/staging/batman-adv/unicast.c | 8 ++++++--
> drivers/staging/batman-adv/unicast.h | 2 +-
> 3 files changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/staging/batman-adv/routing.c
> b/drivers/staging/batman-adv/routing.c index e12fd99..e545260 100644
> --- a/drivers/staging/batman-adv/routing.c
> +++ b/drivers/staging/batman-adv/routing.c
> @@ -1232,8 +1232,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,
You must spin_unlock_irqrestore before you return from that function.
Best regards,
Sven
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-09-12 20:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-12 18:56 [PATCH] staging: batman-adv: check kmalloc() return value Vasiliy Kulikov
2010-09-12 19:57 ` Marek Lindner
2010-09-12 20:43 ` Sven Eckelmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox