summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Hutchings <ben@decadent.org.uk>2017-06-18 02:36:32 +0100
committerBen Hutchings <ben@decadent.org.uk>2017-09-15 18:30:50 +0100
commitc5923c011cd546f8e2400f44bbad2b3afc72f535 (patch)
treedb612c8aaed4d9d67577ed27edca2d6de83770e2
parentbd33f9f3f4a8df2e4a6de42a606151bd0bd13d80 (diff)
net: add kfree_skb_list()
Extracted from upstream commit bd8a7036c06c "gre: fix a possible skb leak". This patch adds a kfree_skb_list() helper. Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
-rw-r--r--include/linux/skbuff.h1
-rw-r--r--net/core/skbuff.c20
2 files changed, 13 insertions, 8 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 2af31eb76bd06..42e067bb16c8c 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -534,6 +534,7 @@ static inline struct rtable *skb_rtable(const struct sk_buff *skb)
}
extern void kfree_skb(struct sk_buff *skb);
+extern void kfree_skb_list(struct sk_buff *segs);
extern void consume_skb(struct sk_buff *skb);
extern void __kfree_skb(struct sk_buff *skb);
extern struct sk_buff *__alloc_skb(unsigned int size,
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index b30d9c2fd5bd5..847b314b3a706 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -277,15 +277,8 @@ EXPORT_SYMBOL(dev_alloc_skb);
static void skb_drop_list(struct sk_buff **listp)
{
- struct sk_buff *list = *listp;
-
+ kfree_skb_list(*listp);
*listp = NULL;
-
- do {
- struct sk_buff *this = list;
- list = list->next;
- kfree_skb(this);
- } while (list);
}
static inline void skb_drop_fraglist(struct sk_buff *skb)
@@ -436,6 +429,17 @@ void kfree_skb(struct sk_buff *skb)
}
EXPORT_SYMBOL(kfree_skb);
+void kfree_skb_list(struct sk_buff *segs)
+{
+ while (segs) {
+ struct sk_buff *next = segs->next;
+
+ kfree_skb(segs);
+ segs = next;
+ }
+}
+EXPORT_SYMBOL(kfree_skb_list);
+
/**
* consume_skb - free an skbuff
* @skb: buffer to free