All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pan Bian <bianpan2016@163.com>
To: Steffen Klassert <steffen.klassert@secunet.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	"David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	Pan Bian <bianpan2013@163.com>
Subject: [net] xfrm_user: use xfrm_state_put to free xfrm_state_alloc return value
Date: Wed, 21 Nov 2018 14:57:48 +0800	[thread overview]
Message-ID: <1542783468-67482-1-git-send-email-bianpan2016@163.com> (raw)

From: Pan Bian <bianpan2013@163.com>

The memory chunk allocated by xfrm_state_alloc() should be released with
xfrm_state_put(), not kfree.

Signed-off-by: Pan Bian <bianpan2013@163.com>
---
 net/xfrm/xfrm_user.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index c9a84e2..267922c 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -2288,13 +2288,13 @@ static int xfrm_add_acquire(struct sk_buff *skb, struct nlmsghdr *nlh,
 
 	}
 
-	kfree(x);
+	xfrm_state_put(x);
 	kfree(xp);
 
 	return 0;
 
 free_state:
-	kfree(x);
+	xfrm_state_put(x);
 nomem:
 	return err;
 }
-- 
2.7.4



             reply	other threads:[~2018-11-21  6:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-21  6:57 Pan Bian [this message]
2018-11-21  8:00 ` [net] xfrm_user: use xfrm_state_put to free xfrm_state_alloc return value Herbert Xu
2018-11-21 20:09   ` Mathias Krause
2018-11-22 14:43     ` Herbert Xu
2018-11-27  7:55       ` Steffen Klassert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1542783468-67482-1-git-send-email-bianpan2016@163.com \
    --to=bianpan2016@163.com \
    --cc=bianpan2013@163.com \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=steffen.klassert@secunet.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.