devlink: Fix resource coverity errors
Fix resource coverity errors.
Fixes: d9f9b9a4d0
("devlink: Add support for resource abstraction")
Signed-off-by: Arkadi Sharshevsky <arkadis@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
c7272c2f12
commit
3d18e4f19f
|
@ -1695,10 +1695,11 @@ static int devlink_dpipe_table_put(struct sk_buff *skb,
|
|||
goto nla_put_failure;
|
||||
|
||||
if (table->resource_valid) {
|
||||
nla_put_u64_64bit(skb, DEVLINK_ATTR_DPIPE_TABLE_RESOURCE_ID,
|
||||
table->resource_id, DEVLINK_ATTR_PAD);
|
||||
nla_put_u64_64bit(skb, DEVLINK_ATTR_DPIPE_TABLE_RESOURCE_UNITS,
|
||||
table->resource_units, DEVLINK_ATTR_PAD);
|
||||
if (nla_put_u64_64bit(skb, DEVLINK_ATTR_DPIPE_TABLE_RESOURCE_ID,
|
||||
table->resource_id, DEVLINK_ATTR_PAD) ||
|
||||
nla_put_u64_64bit(skb, DEVLINK_ATTR_DPIPE_TABLE_RESOURCE_UNITS,
|
||||
table->resource_units, DEVLINK_ATTR_PAD))
|
||||
goto nla_put_failure;
|
||||
}
|
||||
if (devlink_dpipe_matches_put(table, skb))
|
||||
goto nla_put_failure;
|
||||
|
@ -2372,20 +2373,22 @@ static int devlink_nl_cmd_resource_set(struct sk_buff *skb,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
static int
|
||||
devlink_resource_size_params_put(struct devlink_resource *resource,
|
||||
struct sk_buff *skb)
|
||||
{
|
||||
struct devlink_resource_size_params *size_params;
|
||||
|
||||
size_params = resource->size_params;
|
||||
nla_put_u64_64bit(skb, DEVLINK_ATTR_RESOURCE_SIZE_GRAN,
|
||||
size_params->size_granularity, DEVLINK_ATTR_PAD);
|
||||
nla_put_u64_64bit(skb, DEVLINK_ATTR_RESOURCE_SIZE_MAX,
|
||||
size_params->size_max, DEVLINK_ATTR_PAD);
|
||||
nla_put_u64_64bit(skb, DEVLINK_ATTR_RESOURCE_SIZE_MIN,
|
||||
size_params->size_min, DEVLINK_ATTR_PAD);
|
||||
nla_put_u8(skb, DEVLINK_ATTR_RESOURCE_UNIT, size_params->unit);
|
||||
if (nla_put_u64_64bit(skb, DEVLINK_ATTR_RESOURCE_SIZE_GRAN,
|
||||
size_params->size_granularity, DEVLINK_ATTR_PAD) ||
|
||||
nla_put_u64_64bit(skb, DEVLINK_ATTR_RESOURCE_SIZE_MAX,
|
||||
size_params->size_max, DEVLINK_ATTR_PAD) ||
|
||||
nla_put_u64_64bit(skb, DEVLINK_ATTR_RESOURCE_SIZE_MIN,
|
||||
size_params->size_min, DEVLINK_ATTR_PAD) ||
|
||||
nla_put_u8(skb, DEVLINK_ATTR_RESOURCE_UNIT, size_params->unit))
|
||||
return -EMSGSIZE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int devlink_resource_put(struct devlink *devlink, struct sk_buff *skb,
|
||||
|
@ -2409,10 +2412,12 @@ static int devlink_resource_put(struct devlink *devlink, struct sk_buff *skb,
|
|||
nla_put_u64_64bit(skb, DEVLINK_ATTR_RESOURCE_SIZE_NEW,
|
||||
resource->size_new, DEVLINK_ATTR_PAD);
|
||||
if (resource->resource_ops && resource->resource_ops->occ_get)
|
||||
nla_put_u64_64bit(skb, DEVLINK_ATTR_RESOURCE_OCC,
|
||||
resource->resource_ops->occ_get(devlink),
|
||||
DEVLINK_ATTR_PAD);
|
||||
devlink_resource_size_params_put(resource, skb);
|
||||
if (nla_put_u64_64bit(skb, DEVLINK_ATTR_RESOURCE_OCC,
|
||||
resource->resource_ops->occ_get(devlink),
|
||||
DEVLINK_ATTR_PAD))
|
||||
goto nla_put_failure;
|
||||
if (devlink_resource_size_params_put(resource, skb))
|
||||
goto nla_put_failure;
|
||||
if (list_empty(&resource->resource_list))
|
||||
goto out;
|
||||
|
||||
|
|
Loading…
Reference in a new issue