xfrm: Fix error reporting in xfrm_state_construct.
authorSteffen Klassert <steffen.klassert@secunet.com>
Mon, 7 Jun 2021 13:21:49 +0000 (15:21 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 19 Jul 2021 07:44:49 +0000 (09:44 +0200)
commit57f7ed25bd1672a51c2d9cd15c9714c0dfc56062
tree880e7a81709b96ad064b2191ba19723b5c5379ec
parenta5f8862967c453aff5b32883d1b6be8e2009e4f0
xfrm: Fix error reporting in xfrm_state_construct.

[ Upstream commit 6fd06963fa74197103cdbb4b494763127b3f2f34 ]

When memory allocation for XFRMA_ENCAP or XFRMA_COADDR fails,
the error will not be reported because the -ENOMEM assignment
to the err variable is overwritten before. Fix this by moving
these two in front of the function so that memory allocation
failures will be reported.

Reported-by: Tobias Brunner <tobias@strongswan.org>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/xfrm/xfrm_user.c