Commit 50126302 authored by Simon Ruderich's avatar Simon Ruderich
Browse files

slsm: tree: fix memory leak on success and error path

parent 0911d770
......@@ -264,28 +264,34 @@ ssize_t slsm_serialize_subtree(struct slsm_str *buf, struct slsm_str *path_buf,
ssize_t slsm_serialize_tree(char **retbuf) {
ssize_t ret;
struct slsm_str buf;
struct slsm_str path_buf;
struct slsm_str buf = {};
struct slsm_str path_buf = {};
if (!rules)
return 0;
ret = slsm_str_init(&buf, 4096);
if (ret)
return ret;
ret = slsm_str_init(&path_buf, 4096);
if (ret)
return ret;
goto out;
ret = slsm_str_init(&buf, 4096);
if (ret)
goto out;
mutex_lock(&mutex);
ret = slsm_serialize_subtree(&buf, &path_buf, rules);
mutex_unlock(&mutex);
if (ret)
return ret;
if (ret) {
kfree(buf.buf);
goto out;
}
*retbuf = buf.buf;
return (ssize_t)buf.used;
ret = (ssize_t)buf.used;
out:
kfree(path_buf.buf);
return ret;
}
......
Supports Markdown
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