UPSTREAM: net: xfrm: fix memory leak in xfrm_user_policy()
if xfrm_get_translator() failed, xfrm_user_policy() return without
freeing 'data', which is allocated in memdup_sockptr().
Fixes: 96392ee5a13b ("xfrm/compat: Translate 32-bit user_policy from sockptr")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
(cherry picked from commit 48f486e13ffdb49fbb9b38c21d0e108ed60ab1a2)
Bug: 187129171
Signed-off-by: Connor O'Brien <connoro@google.com>
Change-Id: If018bce68d0d23491f1c47299443f7011dce3e89
This commit is contained in:
parent
7db1c96c2d
commit
dee5558ec9
1 changed files with 3 additions and 1 deletions
|
|
@ -2381,8 +2381,10 @@ int xfrm_user_policy(struct sock *sk, int optname, u8 __user *optval, int optlen
|
|||
if (in_compat_syscall()) {
|
||||
struct xfrm_translator *xtr = xfrm_get_translator();
|
||||
|
||||
if (!xtr)
|
||||
if (!xtr) {
|
||||
kfree(data);
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
err = xtr->xlate_user_policy_sockptr(&data, optlen);
|
||||
xfrm_put_translator(xtr);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue