kernel: add missing kfree, use proper return code

* This is half picked from 559be41482
* We haven't sync latest upstream changes yet

Signed-off-by: Faris <rissu.ntk@gmail.com>
This commit is contained in:
Wang Han
2025-11-09 20:29:26 +07:00
committed by ShirkNeko
parent a2211e2909
commit d36371580b
2 changed files with 7 additions and 6 deletions

View File

@@ -382,21 +382,20 @@ static void do_persistent_allow_list(struct callback_head *_cb)
if (IS_ERR(fp)) {
pr_err("save_allow_list create file failed: %ld\n",
PTR_ERR(fp));
mutex_unlock(&allowlist_mutex);
return;
goto unlock;
}
// store magic and version
if (ksu_kernel_write_compat(fp, &magic, sizeof(magic), &off) !=
sizeof(magic)) {
pr_err("save_allow_list write magic failed.\n");
goto exit;
goto close_file;
}
if (ksu_kernel_write_compat(fp, &version, sizeof(version), &off) !=
sizeof(version)) {
pr_err("save_allow_list write version failed.\n");
goto exit;
goto close_file;
}
list_for_each (pos, &allow_list) {
@@ -409,9 +408,11 @@ static void do_persistent_allow_list(struct callback_head *_cb)
&off);
}
exit:
close_file:
filp_close(fp, 0);
unlock:
mutex_unlock(&allowlist_mutex);
kfree(_cb);
}
void persistent_allow_list(void)