diff mbox series

[net] chelsio/chtls: fix memory leak

Message ID 20201102173909.24826-1-vinay.yadav@chelsio.com
State New
Headers show
Series [net] chelsio/chtls: fix memory leak | expand

Commit Message

Vinay Kumar Yadav Nov. 2, 2020, 5:39 p.m. UTC
Correct skb refcount in alloc_ctrl_skb(), causing skb memleak
when chtls_send_abort() called with NULL skb.
it was always leaking the skb, correct it by incrementing skb
refs by one.

Fixes: cc35c88ae4db ("crypto : chtls - CPL handler definition")
Signed-off-by: Vinay Kumar Yadav <vinay.yadav@chelsio.com>
---
 drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_cm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jakub Kicinski Nov. 3, 2020, 9:52 p.m. UTC | #1
On Mon,  2 Nov 2020 23:09:10 +0530 Vinay Kumar Yadav wrote:
> Correct skb refcount in alloc_ctrl_skb(), causing skb memleak

> when chtls_send_abort() called with NULL skb.

> it was always leaking the skb, correct it by incrementing skb

> refs by one.

> 

> Fixes: cc35c88ae4db ("crypto : chtls - CPL handler definition")

> Signed-off-by: Vinay Kumar Yadav <vinay.yadav@chelsio.com>


Applied the two memory leak fixes, but I had to adjust the subjects.
They were too similar.

Thanks!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_cm.c b/drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_cm.c
index 24154816d1d1..63aacc184f68 100644
--- a/drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_cm.c
+++ b/drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_cm.c
@@ -212,7 +212,7 @@  static struct sk_buff *alloc_ctrl_skb(struct sk_buff *skb, int len)
 {
 	if (likely(skb && !skb_shared(skb) && !skb_cloned(skb))) {
 		__skb_trim(skb, 0);
-		refcount_add(2, &skb->users);
+		refcount_inc(&skb->users);
 	} else {
 		skb = alloc_skb(len, GFP_KERNEL | __GFP_NOFAIL);
 	}