From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx> Date: Sun, 31 Dec 2023 09:23:50 +0100 The kfree() function was called in one case by the add_links() function during error handling even if the passed variable contained a null pointer. This issue was detected by using the Coccinelle software. Thus use another label. Signed-off-by: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx> --- kernel/gcov/fs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/gcov/fs.c b/kernel/gcov/fs.c index 10916c70fad9..80c221bb7f20 100644 --- a/kernel/gcov/fs.c +++ b/kernel/gcov/fs.c @@ -490,7 +490,8 @@ static void add_links(struct gcov_node *node, struct dentry *parent) gcov_info_filename(get_node_info(node)), &gcov_link[i]); if (!target) - goto out_err; + goto remove_links; + basename = kbasename(target); if (basename == target) goto out_err; @@ -502,6 +503,7 @@ static void add_links(struct gcov_node *node, struct dentry *parent) return; out_err: kfree(target); +remove_links: while (i-- > 0) debugfs_remove(node->links[i]); kfree(node->links); -- 2.43.0