diff options
author | Jacob Keller <jacob.e.keller@intel.com> | 2020-03-26 11:37:14 -0700 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2020-03-26 19:39:26 -0700 |
commit | 7ef19d3b1d5e2e1dad64d41df708638f20c5917f (patch) | |
tree | 004a1abb6579426f71960fac61ac2b70be1595b4 /drivers/net/netdevsim/dev.c | |
parent | 7000108f27b1b421d388af0da0edc1d9cf13fd3c (diff) | |
download | lwn-7ef19d3b1d5e2e1dad64d41df708638f20c5917f.tar.gz lwn-7ef19d3b1d5e2e1dad64d41df708638f20c5917f.zip |
devlink: report error once U32_MAX snapshot ids have been used
The devlink_snapshot_id_get() function returns a snapshot id. The
snapshot id is a u32, so there is no way to indicate an error code.
A future change is going to possibly add additional cases where this
function could fail. Refactor the function to return the snapshot id in
an argument, so that it can return zero or an error value.
This ensures that snapshot ids cannot be confused with error values, and
aids in the future refactor of snapshot id allocation management.
Because there is no current way to release previously used snapshot ids,
add a simple check ensuring that an error is reported in case the
snapshot_id would over flow.
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Reviewed-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/netdevsim/dev.c')
-rw-r--r-- | drivers/net/netdevsim/dev.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/net/netdevsim/dev.c b/drivers/net/netdevsim/dev.c index f7621ccb7b88..609005f2ac85 100644 --- a/drivers/net/netdevsim/dev.c +++ b/drivers/net/netdevsim/dev.c @@ -54,7 +54,11 @@ static ssize_t nsim_dev_take_snapshot_write(struct file *file, get_random_bytes(dummy_data, NSIM_DEV_DUMMY_REGION_SIZE); - id = devlink_region_snapshot_id_get(priv_to_devlink(nsim_dev)); + err = devlink_region_snapshot_id_get(priv_to_devlink(nsim_dev), &id); + if (err) { + pr_err("Failed to get snapshot id\n"); + return err; + } err = devlink_region_snapshot_create(nsim_dev->dummy_region, dummy_data, id); if (err) { |