From: Colin Ian King Date: Mon, 22 Jan 2018 10:31:19 +0000 (+0000) Subject: devlink: fix memory leak on 'resource' X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=b75703de16301b80f1eedecafdf37bb02c9e155f;p=linux.git devlink: fix memory leak on 'resource' 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 Acked-by: Jiri Pirko Signed-off-by: David S. Miller --- diff --git a/net/core/devlink.c b/net/core/devlink.c index 66d36705fb9db..18d385ed82370 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -3182,6 +3182,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; }