mirror of
https://github.com/torvalds/linux.git
synced 2024-11-10 22:21:40 +00:00
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: 7ef19d3b1d
("devlink: report error once U32_MAX snapshot ids have been used")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Reviewed-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
1a795da798
commit
3902baf9ab
@ -75,6 +75,7 @@ static ssize_t nsim_dev_take_snapshot_write(struct file *file,
|
|||||||
err = devlink_region_snapshot_id_get(devlink, &id);
|
err = devlink_region_snapshot_id_get(devlink, &id);
|
||||||
if (err) {
|
if (err) {
|
||||||
pr_err("Failed to get snapshot id\n");
|
pr_err("Failed to get snapshot id\n");
|
||||||
|
kfree(dummy_data);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
err = devlink_region_snapshot_create(nsim_dev->dummy_region,
|
err = devlink_region_snapshot_create(nsim_dev->dummy_region,
|
||||||
|
Loading…
Reference in New Issue
Block a user