[PATCH 3/3] gcov: Improve exception handling in add_links()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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






[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux