Commit 3902baf9 authored by Gustavo A. R. Silva's avatar Gustavo A. R. Silva Committed by David S. Miller

netdevsim: dev: Fix memory leak in nsim_dev_take_snapshot_write

In case memory resources for dummy_data were allocated, release them
before return.

Addresses-Coverity-ID: 1491997 ("Resource leak")
Fixes: 7ef19d3b ("devlink: report error once U32_MAX snapshot ids have been used")
Signed-off-by: default avatarGustavo A. R. Silva <gustavo@embeddedor.com>
Reviewed-by: default avatarJakub Kicinski <kuba@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 1a795da7
......@@ -75,6 +75,7 @@ static ssize_t nsim_dev_take_snapshot_write(struct file *file,
err = devlink_region_snapshot_id_get(devlink, &id);
if (err) {
pr_err("Failed to get snapshot id\n");
kfree(dummy_data);
return err;
}
err = devlink_region_snapshot_create(nsim_dev->dummy_region,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment