mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 18:09:56 +00:00
net: ipv4: fix a memleak in ip_setup_cork
[ Upstream commit5dee6d6923] When inetdev_valid_mtu fails, cork->opt should be freed if it is allocated in ip_setup_cork. Otherwise there could be a memleak. Fixes:501a90c945("inet: protect against too small mtu values.") Signed-off-by: Zhipeng Lu <alexious@zju.edu.cn> Reviewed-by: Eric Dumazet <edumazet@google.com> Link: https://lore.kernel.org/r/20240129091017.2938835-1-alexious@zju.edu.cn Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
38cc160533
commit
205659dbb8
@@ -1287,6 +1287,12 @@ static int ip_setup_cork(struct sock *sk, struct inet_cork *cork,
|
|||||||
if (unlikely(!rt))
|
if (unlikely(!rt))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
|
cork->fragsize = ip_sk_use_pmtu(sk) ?
|
||||||
|
dst_mtu(&rt->dst) : READ_ONCE(rt->dst.dev->mtu);
|
||||||
|
|
||||||
|
if (!inetdev_valid_mtu(cork->fragsize))
|
||||||
|
return -ENETUNREACH;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* setup for corking.
|
* setup for corking.
|
||||||
*/
|
*/
|
||||||
@@ -1303,12 +1309,6 @@ static int ip_setup_cork(struct sock *sk, struct inet_cork *cork,
|
|||||||
cork->addr = ipc->addr;
|
cork->addr = ipc->addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
cork->fragsize = ip_sk_use_pmtu(sk) ?
|
|
||||||
dst_mtu(&rt->dst) : READ_ONCE(rt->dst.dev->mtu);
|
|
||||||
|
|
||||||
if (!inetdev_valid_mtu(cork->fragsize))
|
|
||||||
return -ENETUNREACH;
|
|
||||||
|
|
||||||
cork->gso_size = ipc->gso_size;
|
cork->gso_size = ipc->gso_size;
|
||||||
|
|
||||||
cork->dst = &rt->dst;
|
cork->dst = &rt->dst;
|
||||||
|
|||||||
Reference in New Issue
Block a user