[PATCH][next] devlink: fix memory leak on 'resource'

Subsystems: networking [general], the rest

STALE3128d

3 messages, 3 authors, 2018-01-22 · open the first message on its own page

[PATCH][next] devlink: fix memory leak on 'resource'

From: Colin King <hidden>
Date: 2018-01-22 10:31:25

From: Colin Ian King <redacted>

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 <redacted>
---
 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

Re: [PATCH][next] devlink: fix memory leak on 'resource'

From: Jiri Pirko <jiri@resnulli.us>
Date: 2018-01-22 10:34:17

Mon, Jan 22, 2018 at 11:31:19AM CET, colin.king@canonical.com wrote:
From: Colin Ian King <redacted>

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 <redacted>
Acked-by: Jiri Pirko <redacted>

Thanks.

Re: [PATCH][next] devlink: fix memory leak on 'resource'

From: David Miller <davem@davemloft.net>
Date: 2018-01-22 14:27:40

From: Colin King <redacted>
Date: Mon, 22 Jan 2018 10:31:19 +0000
From: Colin Ian King <redacted>

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 <redacted>
Applied, thanks Colin.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help