diff options
author | Gustavo A. R. Silva <gustavo@embeddedor.com> | 2020-03-30 18:27:02 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2020-03-30 20:14:22 -0700 |
commit | 3902baf9abfa320b21e38fe206d66d5e6688e721 (patch) | |
tree | b2aeca37ae751a6dd186a1b95df15dd875171826 | |
parent | 1a795da798759471cfdc994f5efe998f915f1fd8 (diff) | |
download | linux-3902baf9abfa320b21e38fe206d66d5e6688e721.tar.bz2 |
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: 7ef19d3b1d5e ("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>
-rw-r--r-- | drivers/net/netdevsim/dev.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/net/netdevsim/dev.c b/drivers/net/netdevsim/dev.c index 1fe2a93ad382..68668a22b9dd 100644 --- a/drivers/net/netdevsim/dev.c +++ b/drivers/net/netdevsim/dev.c @@ -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, |