Commit b75703de authored by Colin Ian King's avatar Colin Ian King Committed by David S. Miller

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: d9f9b9a4 ("devlink: Add support for resource abstraction")
Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2ae50dea
...@@ -3182,6 +3182,7 @@ int devlink_resource_register(struct devlink *devlink, ...@@ -3182,6 +3182,7 @@ int devlink_resource_register(struct devlink *devlink,
resource_list = &parent_resource->resource_list; resource_list = &parent_resource->resource_list;
resource->parent = parent_resource; resource->parent = parent_resource;
} else { } else {
kfree(resource);
err = -EINVAL; err = -EINVAL;
goto out; goto out;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment