mirror of
https://github.com/torvalds/linux.git
synced 2024-11-23 12:42:02 +00:00
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: 96392ee5a1
("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>
This commit is contained in:
parent
bc0230b646
commit
48f486e13f
@ -2382,8 +2382,10 @@ int xfrm_user_policy(struct sock *sk, int optname, sockptr_t 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…
Reference in New Issue
Block a user