2020-03-30 23:27:49

by Gustavo A. R. Silva

[permalink] [raw]
Subject: [PATCH net-next] 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 <[email protected]>
---
drivers/net/netdevsim/dev.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/net/netdevsim/dev.c b/drivers/net/netdevsim/dev.c
index 2b727a7001f6..9897e9a0e26f 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,
--
2.23.0


2020-03-30 23:39:34

by Jakub Kicinski

[permalink] [raw]
Subject: Re: [PATCH net-next] netdevsim: dev: Fix memory leak in nsim_dev_take_snapshot_write

On Mon, 30 Mar 2020 18:27:02 -0500 Gustavo A. R. Silva wrote:
> 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 <[email protected]>

Reviewed-by: Jakub Kicinski <[email protected]>

2020-03-31 03:15:08

by David Miller

[permalink] [raw]
Subject: Re: [PATCH net-next] netdevsim: dev: Fix memory leak in nsim_dev_take_snapshot_write

From: "Gustavo A. R. Silva" <[email protected]>
Date: Mon, 30 Mar 2020 18:27:02 -0500

> 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 <[email protected]>

Applied, thanks.

2020-03-31 17:00:20

by Jacob Keller

[permalink] [raw]
Subject: RE: [PATCH net-next] netdevsim: dev: Fix memory leak in nsim_dev_take_snapshot_write



> -----Original Message-----
> From: Gustavo A. R. Silva <[email protected]>
> Sent: Monday, March 30, 2020 4:27 PM
> To: Jakub Kicinski <[email protected]>; David S. Miller <[email protected]>;
> Keller, Jacob E <[email protected]>; Jiri Pirko <[email protected]>
> Cc: [email protected]; [email protected]; Gustavo A. R. Silva
> <[email protected]>
> Subject: [PATCH net-next] 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 <[email protected]>
> ---

Ahh! Thanks!

Belated Reviewed-by: Jacob Keller <[email protected]>