提交 b75703de 编写于 作者: C Colin Ian King 提交者: 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: NColin Ian King <colin.king@canonical.com>
Acked-by: NJiri Pirko <jiri@mellanox.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 2ae50dea
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册