netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] net: dsa: skb_put_padto() already frees nskb
@ 2017-08-21 19:41 Florian Fainelli
  2017-08-22 18:27 ` David Miller
  0 siblings, 1 reply; 7+ messages in thread
From: Florian Fainelli @ 2017-08-21 19:41 UTC (permalink / raw)
  To: netdev; +Cc: davem, andrew, vivien.didtelot, woojung.huh, Florian Fainelli

skb_put_padto() already frees the passed sk_buff reference upon error,
so calling kfree_skb() on it again is not necessary.

Detected by CoverityScan, CID#1416687 ("USE_AFTER_FREE")

Fixes: e71cb9e00922 ("net: dsa: ksz: fix skb freeing")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 net/dsa/tag_ksz.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/net/dsa/tag_ksz.c b/net/dsa/tag_ksz.c
index de66ca8e6201..107172c82107 100644
--- a/net/dsa/tag_ksz.c
+++ b/net/dsa/tag_ksz.c
@@ -60,10 +60,8 @@ static struct sk_buff *ksz_xmit(struct sk_buff *skb, struct net_device *dev)
 					 skb_transport_header(skb) - skb->head);
 		skb_copy_and_csum_dev(skb, skb_put(nskb, skb->len));
 
-		if (skb_put_padto(nskb, nskb->len + padlen)) {
-			kfree_skb(nskb);
+		if (skb_put_padto(nskb, nskb->len + padlen))
 			return NULL;
-		}
 
 		kfree_skb(skb);
 	}
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 7+ messages in thread
* [PATCH net] net: dsa: skb_put_padto() already frees nskb
@ 2017-08-21 19:41 Florian Fainelli
  2017-08-21 19:47 ` Andrew Lunn
  2017-08-21 22:15 ` Woojung.Huh
  0 siblings, 2 replies; 7+ messages in thread
From: Florian Fainelli @ 2017-08-21 19:41 UTC (permalink / raw)
  To: netdev; +Cc: davem, andrew, vivien.didelot, woojung.huh, Florian Fainelli

skb_put_padto() already frees the passed sk_buff reference upon error,
so calling kfree_skb() on it again is not necessary.

Detected by CoverityScan, CID#1416687 ("USE_AFTER_FREE")

Fixes: e71cb9e00922 ("net: dsa: ksz: fix skb freeing")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 net/dsa/tag_ksz.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/net/dsa/tag_ksz.c b/net/dsa/tag_ksz.c
index de66ca8e6201..107172c82107 100644
--- a/net/dsa/tag_ksz.c
+++ b/net/dsa/tag_ksz.c
@@ -60,10 +60,8 @@ static struct sk_buff *ksz_xmit(struct sk_buff *skb, struct net_device *dev)
 					 skb_transport_header(skb) - skb->head);
 		skb_copy_and_csum_dev(skb, skb_put(nskb, skb->len));
 
-		if (skb_put_padto(nskb, nskb->len + padlen)) {
-			kfree_skb(nskb);
+		if (skb_put_padto(nskb, nskb->len + padlen))
 			return NULL;
-		}
 
 		kfree_skb(skb);
 	}
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-08-22 18:27 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-21 19:41 [PATCH net] net: dsa: skb_put_padto() already frees nskb Florian Fainelli
2017-08-22 18:27 ` David Miller
  -- strict thread matches above, loose matches on Subject: below --
2017-08-21 19:41 Florian Fainelli
2017-08-21 19:47 ` Andrew Lunn
2017-08-21 22:15 ` Woojung.Huh
2017-08-21 22:24   ` Florian Fainelli
2017-08-22 18:01     ` Woojung.Huh

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).