Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Simon Ruderich
passt-mac
Commits
53f9d273
Commit
53f9d273
authored
Aug 20, 2016
by
Simon Ruderich
Browse files
slsm: tree: slsm_insert_helper: fix memory leak in error path
parent
c7f2d339
Changes
1
Show whitespace changes
Inline
Side-by-side
security/slsm/tree.c
View file @
53f9d273
...
...
@@ -307,7 +307,7 @@ out:
/**
* @t: root of the tree in which the rule should be inserted
* @path: where the rule is to be inserted, takes ownership
* @rule: the rule, will be copied
* @rule: the rule, will be copied
, takes ownership of references (e.g. app)
*
* Returns: 0 or error value
*/
...
...
@@ -316,8 +316,11 @@ static int slsm_insert_helper(struct tree_node *t, char *path,
char
*
component
,
*
next
=
path
+
1
;
/* skip leading slash */
struct
tree_node
*
t_next
=
t
;
if
(
!*
path
||
*
path
!=
'/'
)
if
(
!*
path
||
*
path
!=
'/'
)
{
kfree
(
path
);
kfree
(
rule
->
app
);
return
-
EINVAL
;
}
if
(
!*
next
)
{
/* / is target node, we're already there */
...
...
@@ -350,7 +353,7 @@ static int slsm_insert_helper(struct tree_node *t, char *path,
GFP_KERNEL
);
if
(
!
more_children
)
{
kfree
(
path
);
/* no reference stored so far */
return
-
ENOMEM
;
goto
enomem
;
}
t
->
children
=
more_children
;
...
...
@@ -371,7 +374,7 @@ static int slsm_insert_helper(struct tree_node *t, char *path,
if
(
!
t
->
children
)
/* what we alloced so far is already referenced and
* consistent, leave it in place */
return
-
ENOMEM
;
goto
enomem
;
t
->
children
[
t
->
children_used
]
=
(
struct
tree_node
){
.
name
=
component
};
...
...
@@ -392,7 +395,7 @@ insert_rule:
new_capacity
*
sizeof
(
*
more_rules
),
GFP_KERNEL
);
if
(
!
more_rules
)
return
-
ENOMEM
;
goto
enomem
;
t
->
rules
=
more_rules
;
t
->
rules_capacity
=
new_capacity
;
...
...
@@ -402,6 +405,10 @@ insert_rule:
t
->
rules_used
++
;
return
0
;
enomem:
kfree
(
rule
->
app
);
return
-
ENOMEM
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment