diff options
author | Gavrilov Ilia <Ilia.Gavrilov@infotecs.ru> | 2022-12-08 11:31:39 +0300 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2022-12-10 07:04:32 +0300 |
commit | 5fc11a401a8dc491b326d2c916b07d22e7ac8833 (patch) | |
tree | a6a15672c504a2eac494c98f58067b2d1516a953 /net/core | |
parent | ce098da1497c6dee9589fce2c61d1910f4fcf0e7 (diff) | |
download | linux-5fc11a401a8dc491b326d2c916b07d22e7ac8833.tar.xz |
net: devlink: Add missing error check to devlink_resource_put()
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>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/devlink.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/net/core/devlink.c b/net/core/devlink.c index ab40ebcb4aea..6004bd0ccee4 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -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)) |