xfrm: fix the if_id check in changelink
authorAntony Antony <antony.antony@secunet.com>
Tue, 1 Feb 2022 06:51:57 +0000 (07:51 +0100)
committerSteffen Klassert <steffen.klassert@secunet.com>
Thu, 3 Feb 2022 07:02:05 +0000 (08:02 +0100)
if_id will be always 0, because it was not yet initialized.

Fixes: 8dce43919566 ("xfrm: interface with if_id 0 should return error")
Reported-by: Pavel Machek <pavel@denx.de>
Signed-off-by: Antony Antony <antony.antony@secunet.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
net/xfrm/xfrm_interface.c

index 57448fc519fcd9b6b09f66bcaf996ceb9b34f8d8..4e3c62d1ad9e91aead01b88d3c0ebe824bc29235 100644 (file)
@@ -673,12 +673,12 @@ static int xfrmi_changelink(struct net_device *dev, struct nlattr *tb[],
        struct net *net = xi->net;
        struct xfrm_if_parms p = {};
 
+       xfrmi_netlink_parms(data, &p);
        if (!p.if_id) {
                NL_SET_ERR_MSG(extack, "if_id must be non zero");
                return -EINVAL;
        }
 
-       xfrmi_netlink_parms(data, &p);
        xi = xfrmi_locate(net, &p);
        if (!xi) {
                xi = netdev_priv(dev);