* [PATCH 0/2] use stack instead of heap
@ 2013-02-05 20:23 Alexander Aring
[not found] ` <1360095824-12538-1-git-send-email-alex.aring-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-02-06 20:56 ` [PATCH 0/2] use stack " David Miller
0 siblings, 2 replies; 4+ messages in thread
From: Alexander Aring @ 2013-02-05 20:23 UTC (permalink / raw)
To: alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w
Cc: netdev-u79uwXL29TY76Z2rM5mHXA, davem-fT/PcQaiUtIeIZ0/mPfg9Q,
linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
In 6lowpan and mac802154 implemenation is a allocated
temp heap buffer, which can also on the stack.
I hope 100 bytes in 6lowpan are fine.
Alexander Aring (2):
6lowpan: use stack buffer instead of heap
wpan: use stack buffer instead of heap
net/ieee802154/6lowpan.c | 13 ++++---------
net/mac802154/wpan.c | 7 +------
2 files changed, 5 insertions(+), 15 deletions(-)
--
1.8.1.2
------------------------------------------------------------------------------
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] 6lowpan: use stack buffer instead of heap
[not found] ` <1360095824-12538-1-git-send-email-alex.aring-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2013-02-05 20:23 ` Alexander Aring
2013-02-05 20:23 ` [PATCH 2/2] wpan: " Alexander Aring
1 sibling, 0 replies; 4+ messages in thread
From: Alexander Aring @ 2013-02-05 20:23 UTC (permalink / raw)
To: alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w
Cc: netdev-u79uwXL29TY76Z2rM5mHXA, davem-fT/PcQaiUtIeIZ0/mPfg9Q,
linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
head buffer is only temporary available in lowpan_header_create.
So it's not necessary to put it on the heap.
Also fixed a comment codestyle issue.
Signed-off-by: Alexander Aring <alex.aring-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
net/ieee802154/6lowpan.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
index f651da6..2bc5e8f 100644
--- a/net/ieee802154/6lowpan.c
+++ b/net/ieee802154/6lowpan.c
@@ -377,17 +377,14 @@ static int lowpan_header_create(struct sk_buff *skb,
struct ipv6hdr *hdr;
const u8 *saddr = _saddr;
const u8 *daddr = _daddr;
- u8 *head;
+ u8 head[100];
struct ieee802154_addr sa, da;
+ /* TODO:
+ * if this package isn't ipv6 one, where should it be routed?
+ */
if (type != ETH_P_IPV6)
return 0;
- /* TODO:
- * if this package isn't ipv6 one, where should it be routed?
- */
- head = kzalloc(100, GFP_KERNEL);
- if (head == NULL)
- return -ENOMEM;
hdr = ipv6_hdr(skb);
hc06_ptr = head + 2;
@@ -561,8 +558,6 @@ static int lowpan_header_create(struct sk_buff *skb,
skb_pull(skb, sizeof(struct ipv6hdr));
memcpy(skb_push(skb, hc06_ptr - head), head, hc06_ptr - head);
- kfree(head);
-
lowpan_raw_dump_table(__func__, "raw skb data dump", skb->data,
skb->len);
--
1.8.1.2
------------------------------------------------------------------------------
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] wpan: use stack buffer instead of heap
[not found] ` <1360095824-12538-1-git-send-email-alex.aring-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-02-05 20:23 ` [PATCH 1/2] 6lowpan: use stack buffer " Alexander Aring
@ 2013-02-05 20:23 ` Alexander Aring
1 sibling, 0 replies; 4+ messages in thread
From: Alexander Aring @ 2013-02-05 20:23 UTC (permalink / raw)
To: alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w
Cc: netdev-u79uwXL29TY76Z2rM5mHXA, davem-fT/PcQaiUtIeIZ0/mPfg9Q,
linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
head buffer is only temporary available in mac802154_header_create.
So it's not necessary to put it on the heap.
Signed-off-by: Alexander Aring <alex.aring-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
net/mac802154/wpan.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/net/mac802154/wpan.c b/net/mac802154/wpan.c
index 98c867b..d20c6d3 100644
--- a/net/mac802154/wpan.c
+++ b/net/mac802154/wpan.c
@@ -137,16 +137,12 @@ static int mac802154_header_create(struct sk_buff *skb,
struct ieee802154_addr dev_addr;
struct mac802154_sub_if_data *priv = netdev_priv(dev);
int pos = 2;
- u8 *head;
+ u8 head[MAC802154_FRAME_HARD_HEADER_LEN];
u16 fc;
if (!daddr)
return -EINVAL;
- head = kzalloc(MAC802154_FRAME_HARD_HEADER_LEN, GFP_KERNEL);
- if (head == NULL)
- return -ENOMEM;
-
head[pos++] = mac_cb(skb)->seq; /* DSN/BSN */
fc = mac_cb_type(skb);
@@ -210,7 +206,6 @@ static int mac802154_header_create(struct sk_buff *skb,
head[1] = fc >> 8;
memcpy(skb_push(skb, pos), head, pos);
- kfree(head);
return pos;
}
--
1.8.1.2
------------------------------------------------------------------------------
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] use stack instead of heap
2013-02-05 20:23 [PATCH 0/2] use stack instead of heap Alexander Aring
[not found] ` <1360095824-12538-1-git-send-email-alex.aring-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2013-02-06 20:56 ` David Miller
1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2013-02-06 20:56 UTC (permalink / raw)
To: alex.aring; +Cc: alex.bluesman.smirnov, dbaryshkov, linux-zigbee-devel, netdev
From: Alexander Aring <alex.aring@gmail.com>
Date: Tue, 5 Feb 2013 21:23:42 +0100
> In 6lowpan and mac802154 implemenation is a allocated
> temp heap buffer, which can also on the stack.
>
> I hope 100 bytes in 6lowpan are fine.
Series applied to net-next, thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-02-06 20:56 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-05 20:23 [PATCH 0/2] use stack instead of heap Alexander Aring
[not found] ` <1360095824-12538-1-git-send-email-alex.aring-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-02-05 20:23 ` [PATCH 1/2] 6lowpan: use stack buffer " Alexander Aring
2013-02-05 20:23 ` [PATCH 2/2] wpan: " Alexander Aring
2013-02-06 20:56 ` [PATCH 0/2] use stack " David Miller
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).