Skip to content

Commit b75703d

Browse files
Colin Ian Kingdavem330
authored andcommitted
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: d9f9b9a ("devlink: Add support for resource abstraction") Signed-off-by: Colin Ian King <[email protected]> Acked-by: Jiri Pirko <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 2ae50de commit b75703d

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

net/core/devlink.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3182,6 +3182,7 @@ int devlink_resource_register(struct devlink *devlink,
31823182
resource_list = &parent_resource->resource_list;
31833183
resource->parent = parent_resource;
31843184
} else {
3185+
kfree(resource);
31853186
err = -EINVAL;
31863187
goto out;
31873188
}

0 commit comments

Comments
 (0)