net: devlink: Add missing error check to devlink_resource_put()
authorGavrilov Ilia <Ilia.Gavrilov@infotecs.ru>
Thu, 8 Dec 2022 08:31:39 +0000 (08:31 +0000)
committerJakub Kicinski <kuba@kernel.org>
Sat, 10 Dec 2022 04:04:32 +0000 (20:04 -0800)
When the resource size changes, the return value of the
'nla_put_u64_64bit' function is not checked. That has been fixed to avoid
rechecking at the next step.

Found by InfoTeCS on behalf of Linux Verification Center
(linuxtesting.org) with SVACE.

Note that this is harmless, we'd error out at the next put().

Signed-off-by: Ilia.Gavrilov <Ilia.Gavrilov@infotecs.ru>
Link: https://lore.kernel.org/r/20221208082821.3927937-1-Ilia.Gavrilov@infotecs.ru
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/core/devlink.c

index ab40ebc..6004bd0 100644 (file)
@@ -4441,9 +4441,10 @@ static int devlink_resource_put(struct devlink *devlink, struct sk_buff *skb,
            nla_put_u64_64bit(skb, DEVLINK_ATTR_RESOURCE_ID, resource->id,
                              DEVLINK_ATTR_PAD))
                goto nla_put_failure;
-       if (resource->size != resource->size_new)
-               nla_put_u64_64bit(skb, DEVLINK_ATTR_RESOURCE_SIZE_NEW,
-                                 resource->size_new, DEVLINK_ATTR_PAD);
+       if (resource->size != resource->size_new &&
+           nla_put_u64_64bit(skb, DEVLINK_ATTR_RESOURCE_SIZE_NEW,
+                             resource->size_new, DEVLINK_ATTR_PAD))
+               goto nla_put_failure;
        if (devlink_resource_occ_put(resource, skb))
                goto nla_put_failure;
        if (devlink_resource_size_params_put(resource, skb))