linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][next] devlink: fix memory leak on 'resource'
@ 2018-01-22 10:31 Colin King
  2018-01-22 10:34 ` Jiri Pirko
  2018-01-22 14:27 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Colin King @ 2018-01-22 10:31 UTC (permalink / raw)
  To: Arkadi Sharshevsky, Jiri Pirko, David S . Miller, netdev
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

Currently, if the call to devlink_resource_find returns null then
the error exit path does not free the devlink_resource 'resource'
and a memory leak occurs. Fix this by kfree'ing resource on the
error exit path.

Detected by CoverityScan, CID#1464184 ("Resource leak")

Fixes: d9f9b9a4d05f ("devlink: Add support for resource abstraction")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 net/core/devlink.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/core/devlink.c b/net/core/devlink.c
index dd7d6dd07bfb..2b6b8eebcda3 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -3181,6 +3181,7 @@ int devlink_resource_register(struct devlink *devlink,
 			resource_list = &parent_resource->resource_list;
 			resource->parent = parent_resource;
 		} else {
+			kfree(resource);
 			err = -EINVAL;
 			goto out;
 		}
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH][next] devlink: fix memory leak on 'resource'
  2018-01-22 10:31 [PATCH][next] devlink: fix memory leak on 'resource' Colin King
@ 2018-01-22 10:34 ` Jiri Pirko
  2018-01-22 14:27 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Jiri Pirko @ 2018-01-22 10:34 UTC (permalink / raw)
  To: Colin King
  Cc: Arkadi Sharshevsky, Jiri Pirko, David S . Miller, netdev,
	kernel-janitors, linux-kernel

Mon, Jan 22, 2018 at 11:31:19AM CET, colin.king@canonical.com wrote:
>From: Colin Ian King <colin.king@canonical.com>
>
>Currently, if the call to devlink_resource_find returns null then
>the error exit path does not free the devlink_resource 'resource'
>and a memory leak occurs. Fix this by kfree'ing resource on the
>error exit path.
>
>Detected by CoverityScan, CID#1464184 ("Resource leak")
>
>Fixes: d9f9b9a4d05f ("devlink: Add support for resource abstraction")
>Signed-off-by: Colin Ian King <colin.king@canonical.com>

Acked-by: Jiri Pirko <jiri@mellanox.com>

Thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH][next] devlink: fix memory leak on 'resource'
  2018-01-22 10:31 [PATCH][next] devlink: fix memory leak on 'resource' Colin King
  2018-01-22 10:34 ` Jiri Pirko
@ 2018-01-22 14:27 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2018-01-22 14:27 UTC (permalink / raw)
  To: colin.king; +Cc: arkadis, jiri, netdev, kernel-janitors, linux-kernel

From: Colin King <colin.king@canonical.com>
Date: Mon, 22 Jan 2018 10:31:19 +0000

> From: Colin Ian King <colin.king@canonical.com>
> 
> Currently, if the call to devlink_resource_find returns null then
> the error exit path does not free the devlink_resource 'resource'
> and a memory leak occurs. Fix this by kfree'ing resource on the
> error exit path.
> 
> Detected by CoverityScan, CID#1464184 ("Resource leak")
> 
> Fixes: d9f9b9a4d05f ("devlink: Add support for resource abstraction")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Applied, thanks Colin.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-01-22 14:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-22 10:31 [PATCH][next] devlink: fix memory leak on 'resource' Colin King
2018-01-22 10:34 ` Jiri Pirko
2018-01-22 14:27 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).