lkml.org 
[lkml]   [2018]   [Jan]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH][next] devlink: fix memory leak on 'resource'
Date
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
\
 
 \ /
  Last update: 2018-01-22 11:31    [W:0.025 / U:21.040 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site